mv plugins to lua

This commit is contained in:
fiplox 2023-01-01 17:04:23 +01:00
parent e8169ca91c
commit d7c4fd7813
19 changed files with 213 additions and 279 deletions

View File

@ -1,106 +0,0 @@
local M = {}
local cmp_nvim_lsp = require 'cmp_nvim_lsp'
M.capabilities = vim.lsp.protocol.make_client_capabilities()
M.capabilities.textDocument.completion.completionItem.snippetSupport = true
-- M.capabilities.offsetEncoding = { "utf-16" }
M.capabilities = cmp_nvim_lsp.default_capabilities(M.capabilities)
-- vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false, scope="cursor"})]]
M.setup = function()
local config = {
virtual_text = true,
signs = false,
underline = true,
update_in_insert = true,
severity_sort = true,
float = {
focusable = true,
style = 'minimal',
border = 'rounded',
source = 'always',
header = '',
prefix = '',
},
}
vim.diagnostic.config(config)
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {
border = 'rounded',
})
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = 'rounded',
})
--[[ local on_references = vim.lsp.handlers['textDocument/references'] ]]
--[[ vim.lsp.handlers['textDocument/references'] = vim.lsp.with(on_references, { ]]
--[[ -- Use location list instead of quickfix list ]]
--[[ loclist = true, ]]
--[[ }) ]]
end
local function lsp_keymaps(bufnr)
local opts = { noremap = true, silent = true }
local keymap = vim.api.nvim_buf_set_keymap
keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
keymap(bufnr, 'n', 'gI', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
keymap(bufnr, 'n', 'gl', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
keymap(bufnr, 'n', '<leader>lf', '<cmd>lua vim.lsp.buf.format { async = true }<cr>', opts)
keymap(bufnr, 'n', '<leader>li', '<cmd>LspInfo<cr>', opts)
keymap(bufnr, 'n', '<leader>lI', '<cmd>LspInstallInfo<cr>', opts)
keymap(bufnr, 'n', '<leader>la', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts)
keymap(bufnr, 'n', '<leader>lj', '<cmd>lua vim.diagnostic.goto_next({buffer=0})<cr>', opts)
keymap(bufnr, 'n', '<leader>lk', '<cmd>lua vim.diagnostic.goto_prev({buffer=0})<cr>', opts)
keymap(bufnr, 'n', '<leader>lr', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
keymap(bufnr, 'n', '<leader>ls', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
keymap(bufnr, 'n', '<leader>lq', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
keymap(bufnr, 'n', '<leader>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
end
M.on_attach = function(client, bufnr)
--[[ vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') ]]
lsp_keymaps(bufnr)
if client.name == 'sumneko_lua' then
client.server_capabilities.documentFormattingProvider = false
end
if client.name == 'clangd' then
client.server_capabilities.documentFormattingProvider = false
end
if client.name == 'gopls' then
client.server_capabilities.documentFormattingProvider = false
end
if client.name == 'jdtls' then
client.server_capabilities.documentFormattingProvider = false
end
if client.name == 'jdt.ls' then
client.server_capabilities.documentFormattingProvider = false
vim.lsp.codelens.refresh()
if JAVA_DAP_ACTIVE then
require('jdtls').setup_dap { hotcodereplace = 'auto' }
require('jdtls.dap').setup_dap_main_class_configs()
end
end
local ft = vim.api.nvim_buf_get_option(bufnr, 'filetype')
local nls = require 'config.plugins.null-ls'
local enable = false
if nls.has_formatter(ft) then
enable = client.name == 'null-ls'
else
enable = not (client.name == 'null-ls')
end
if client.name == 'tsserver' then
enable = false
end
-- util.info(client.name .. " " .. (enable and "yes" or "no"), "format")
client.server_capabilities.documentFormattingProvider = enable
end
return M

View File

@ -1,127 +0,0 @@
local mini = {
'echasnovski/mini.nvim',
event = 'VeryLazy',
}
local specs = { mini, 'JoosepAlviste/nvim-ts-context-commentstring' }
function mini.surround()
require('mini.surround').setup {
mappings = {
add = 'gza', -- Add surrounding in Normal and Visual modes
delete = 'gzd', -- Delete surrounding
find = 'gzf', -- Find surrounding (to the right)
find_left = 'gzF', -- Find surrounding (to the left)
highlight = 'gzh', -- Highlight surrounding
replace = 'gzr', -- Replace surrounding
update_n_lines = 'gzn', -- Update `n_lines`
},
}
end
function mini.jump()
require('mini.jump').setup {}
end
function mini.pairs()
require('mini.pairs').setup {}
end
function mini.comment()
require('mini.comment').setup {
hooks = {
pre = function()
require('ts_context_commentstring.internal').update_commentstring {}
end,
},
}
end
function mini.ai()
local ai = require 'mini.ai'
require('mini.ai').setup {
n_lines = 500,
-- search_method = "cover_or_next",
custom_textobjects = {
o = ai.gen_spec.treesitter({
a = { '@block.outer', '@conditional.outer', '@loop.outer' },
i = { '@block.inner', '@conditional.inner', '@loop.inner' },
}, {}),
f = ai.gen_spec.treesitter({ a = '@function.outer', i = '@function.inner' }, {}),
c = ai.gen_spec.treesitter({ a = '@class.outer', i = '@class.inner' }, {}),
},
}
local map = function(text_obj, desc)
for _, side in ipairs { 'left', 'right' } do
for dir, d in pairs { prev = '[', next = ']' } do
local lhs = d .. (side == 'right' and text_obj:upper() or text_obj:lower())
for _, mode in ipairs { 'n', 'x', 'o' } do
vim.keymap.set(mode, lhs, function()
ai.move_cursor(side, 'a', text_obj, { search_method = dir })
end, {
desc = dir .. ' ' .. desc,
})
end
end
end
end
map('f', 'function')
map('c', 'class')
map('o', 'block')
end
function mini.config()
-- M.jump()
mini.surround()
-- mini.ai()
-- mini.pairs()
mini.comment()
mini.jump()
-- mini.animate()
end
function mini.animate()
local mouse_scrolled = false
for _, scroll in ipairs { 'Up', 'Down' } do
local key = '<ScrollWheel' .. scroll .. '>'
vim.keymap.set('', key, function()
mouse_scrolled = true
return key
end, { remap = true, expr = true })
end
local animate = require 'mini.animate'
vim.go.winwidth = 20
vim.go.winminwidth = 5
animate.setup {
resize = {
timing = animate.gen_timing.linear { duration = 50, unit = 'total' },
},
scroll = {
timing = animate.gen_timing.linear { duration = 100, unit = 'total' },
subscroll = animate.gen_subscroll.equal {
predicate = function(total_scroll)
if mouse_scrolled then
mouse_scrolled = false
return false
end
return total_scroll > 1
end,
},
},
}
end
function mini.init()
vim.keymap.set('n', '<leader>bd', function()
require('mini.bufremove').delete(0, false)
end)
vim.keymap.set('n', '<leader>bD', function()
require('mini.bufremove').delete(0, true)
end)
end
return specs

64
lua/plugins/Comment.lua Normal file
View File

@ -0,0 +1,64 @@
local M = {
'numToStr/Comment.nvim',
event = 'VeryLazy',
}
function M.config()
local comment = require 'Comment'
comment.setup {
-- -LHS of operator-pending mappings in NORMAL and VISUAL mode
opleader = {
---Line-comment keymap
line = 'gc',
---Block-comment keymap
block = 'gb',
},
---LHS of extra mappings
extra = {
---Add comment on the line above
above = 'gcO',
---Add comment on the line below
below = 'gco',
---Add comment at the end of line
eol = 'gca',
},
---Enable keybindings
---NOTE: If given `false` then the plugin won't create any mappings
mappings = {
---Operator-pending mapping; `gcc` `gbc` `gc[count]{motion}` `gb[count]{motion}`
basic = true,
---Extra mapping; `gco`, `gcO`, `gcA`
extra = true,
---Extended mapping; `g>` `g<` `g>[count]{motion}` `g<[count]{motion}`
extended = false,
},
pre_hook = function(ctx)
-- Only calculate commentstring for tsx filetypes
if vim.bo.filetype == 'typescriptreact' then
local U = require 'Comment.utils'
-- Determine whether to use linewise or blockwise commentstring
local type = ctx.ctype == U.ctype.linewise and '__default' or '__multiline'
-- Determine the location where to calculate commentstring from
local location = nil
if ctx.ctype == U.ctype.blockwise then
location = require('ts_context_commentstring.utils').get_cursor_location()
elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then
location = require('ts_context_commentstring.utils').get_visual_start_location()
end
return require('ts_context_commentstring.internal').calculate_commentstring {
key = type,
location = location,
}
end
end,
}
local ft = require 'Comment.ft'
ft({ 's', 'asm' }, '# %s')
end
return M

View File

@ -6,6 +6,7 @@ local M = {
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-cmdline',
'hrsh7th/cmp-path',
'hrsh7th/cmp-calc',
},
}
@ -105,14 +106,14 @@ function M.config()
end
end, { 'i', 's', 'c' }),
},
sources = cmp.config.sources {
sources = {
{ name = 'nvim_lsp' },
{ name = 'snippy' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'calc' },
},
}
cmp.setup.cmdline(':', {
completion = { autocomplete = true },
mapping = {
@ -136,6 +137,7 @@ function M.config()
sources = {
{ name = 'cmdline' },
{ name = 'path' },
{ name = 'calc' },
},
view = {
entries = { name = 'wildmenu', separator = ' · ' },
@ -145,45 +147,13 @@ function M.config()
cmp.setup.cmdline('/', {
completion = { autocomplete = true },
sources = {
{
name = 'buffer',
},
{ name = 'buffer' },
},
view = {
entries = { name = 'wildmenu', separator = ' · ' },
},
})
local config = {
virtual_text = true,
signs = false,
underline = true,
update_in_insert = true,
severity_sort = true,
float = {
focusable = true,
style = 'minimal',
border = 'rounded',
source = 'always',
header = '',
prefix = '',
},
}
vim.diagnostic.config(config)
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {
border = 'rounded',
})
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = 'rounded',
})
--[[ local on_references = vim.lsp.handlers['textDocument/references'] ]]
--[[ vim.lsp.handlers['textDocument/references'] = vim.lsp.with(on_references, { ]]
--[[ -- Use location list instead of quickfix list ]]
--[[ loclist = true, ]]
--[[ }) ]]
end
return M

View File

@ -3,7 +3,12 @@ return {
{ 'honza/vim-snippets', lazy = false },
{ 'dcampos/nvim-snippy', lazy = false },
{ 'dcampos/cmp-snippy', lazy = false },
{ 'kdheepak/lazygit.nvim', cmd = 'LazyGit' },
-- { 'kdheepak/lazygit.nvim', cmd = 'LazyGit' },
{ 'is0n/fm-nvim', cmd = {
'Neomutt',
'Lazygit',
'Lf',
} },
'williamboman/mason-lspconfig.nvim',
{
'phaazon/hop.nvim',

View File

@ -12,7 +12,7 @@ M.tools = {
}
function M.config()
require 'mason'
-- require 'mason'
local lspconfig = require 'lspconfig'
local opts = {}
local cmp_nvim_lsp = require 'cmp_nvim_lsp'
@ -65,7 +65,7 @@ function M.config()
end
end
local ft = vim.api.nvim_buf_get_option(bufnr, 'filetype')
local nls = require 'config.plugins.null-ls'
local nls = require 'plugins.null-ls'
local enable = false
if nls.has_formatter(ft) then
@ -88,7 +88,7 @@ function M.config()
local server = vim.split(tool, '@')[1]
if server == 'sumneko_lua' then
local sumneko_opts = require 'config.plugins.lsp.settings.sumneko_lua'
local sumneko_opts = require 'plugins.lsp.settings.sumneko_lua'
opts = vim.tbl_deep_extend('force', sumneko_opts, opts)
end
if server == 'clangd' then

View File

@ -1,5 +1,6 @@
local M = {
'williamboman/mason.nvim',
cmd = 'Mason',
}
M.tools = {
@ -40,7 +41,7 @@ function M.config()
max_concurrent_installers = 4,
},
}
M.check()
-- M.check()
require('mason-lspconfig').setup {
automatic_installation = false,
}

127
lua/plugins/mini.bak Normal file
View File

@ -0,0 +1,127 @@
local mini = {
'echasnovski/mini.nvim',
event = 'VeryLazy',
}
local specs = { mini, 'JoosepAlviste/nvim-ts-context-commentstring' }
-- function mini.surround()
-- require('mini.surround').setup {
-- mappings = {
-- add = 'gza', -- Add surrounding in Normal and Visual modes
-- delete = 'gzd', -- Delete surrounding
-- find = 'gzf', -- Find surrounding (to the right)
-- find_left = 'gzF', -- Find surrounding (to the left)
-- highlight = 'gzh', -- Highlight surrounding
-- replace = 'gzr', -- Replace surrounding
-- update_n_lines = 'gzn', -- Update `n_lines`
-- },
-- }
-- end
--
-- function mini.jump()
-- require('mini.jump').setup {}
-- end
--
-- function mini.pairs()
-- require('mini.pairs').setup {}
-- end
function mini.comment()
require('mini.comment').setup {
hooks = {
pre = function()
require('ts_context_commentstring.internal').update_commentstring {}
end,
},
}
end
-- function mini.ai()
-- local ai = require 'mini.ai'
-- require('mini.ai').setup {
-- n_lines = 500,
-- -- search_method = "cover_or_next",
-- custom_textobjects = {
-- o = ai.gen_spec.treesitter({
-- a = { '@block.outer', '@conditional.outer', '@loop.outer' },
-- i = { '@block.inner', '@conditional.inner', '@loop.inner' },
-- }, {}),
-- f = ai.gen_spec.treesitter({ a = '@function.outer', i = '@function.inner' }, {}),
-- c = ai.gen_spec.treesitter({ a = '@class.outer', i = '@class.inner' }, {}),
-- },
-- }
--
-- local map = function(text_obj, desc)
-- for _, side in ipairs { 'left', 'right' } do
-- for dir, d in pairs { prev = '[', next = ']' } do
-- local lhs = d .. (side == 'right' and text_obj:upper() or text_obj:lower())
-- for _, mode in ipairs { 'n', 'x', 'o' } do
-- vim.keymap.set(mode, lhs, function()
-- ai.move_cursor(side, 'a', text_obj, { search_method = dir })
-- end, {
-- desc = dir .. ' ' .. desc,
-- })
-- end
-- end
-- end
-- end
--
-- map('f', 'function')
-- map('c', 'class')
-- map('o', 'block')
-- end
function mini.config()
-- M.jump()
-- mini.surround()
-- mini.ai()
-- mini.pairs()
mini.comment()
-- mini.jump()
-- mini.animate()
end
-- function mini.animate()
-- local mouse_scrolled = false
-- for _, scroll in ipairs { 'Up', 'Down' } do
-- local key = '<ScrollWheel' .. scroll .. '>'
-- vim.keymap.set('', key, function()
-- mouse_scrolled = true
-- return key
-- end, { remap = true, expr = true })
-- end
--
-- local animate = require 'mini.animate'
-- vim.go.winwidth = 20
-- vim.go.winminwidth = 5
--
-- animate.setup {
-- resize = {
-- timing = animate.gen_timing.linear { duration = 50, unit = 'total' },
-- },
-- scroll = {
-- timing = animate.gen_timing.linear { duration = 100, unit = 'total' },
-- subscroll = animate.gen_subscroll.equal {
-- predicate = function(total_scroll)
-- if mouse_scrolled then
-- mouse_scrolled = false
-- return false
-- end
-- return total_scroll > 1
-- end,
-- },
-- },
-- }
-- end
function mini.init()
vim.keymap.set('n', '<leader>bd', function()
require('mini.bufremove').delete(0, false)
end)
vim.keymap.set('n', '<leader>bD', function()
require('mini.bufremove').delete(0, true)
end)
end
return specs

View File

@ -36,14 +36,14 @@ function M.config()
enable = true, -- false will disable the whole extension
disable = { 'html' },
},
context_commentstring = { enable = true, config = { css = '// %s' } },
-- context_commentstring = { enable = true, config = { css = '// %s' } },
-- indent = {enable = true, disable = {"python", "html", "javascript"}},
-- TODO seems to be broken
indent = { enable = true, disable = { 'python', 'css' } },
autotag = { enable = true },
autopairs = {
enable = true,
},
indent = { enable = false, disable = { 'python', 'css' } },
-- autotag = { enable = true },
-- autopairs = {
-- enable = true,
-- },
}
end