mirror of
https://github.com/pnx/dotfiles
synced 2026-06-16 19:30:01 +02:00
Update nvim
This commit is contained in:
parent
5286b45f9d
commit
4c1b128c96
15 changed files with 223 additions and 72 deletions
|
|
@ -45,8 +45,7 @@ return {
|
|||
["<S-Tab>"] = selectPrev,
|
||||
["<Down>"] = selectNext,
|
||||
["<Tab>"] = selectNext,
|
||||
-- ["<esc>"] = close without removeing typed text,
|
||||
["<S-space>"] = cmp.mapping.complete(),
|
||||
["<esc>"] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
},
|
||||
snippet = {
|
||||
|
|
@ -54,24 +53,24 @@ return {
|
|||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
-- formatting = {
|
||||
-- fields = { "abbr", "menu", "kind" },
|
||||
-- format = function(entry, vim_item)
|
||||
-- if vim.tbl_contains({ 'path' }, entry.source.name) then
|
||||
-- local icon, hl_group = require('nvim-web-devicons').get_icon(entry:get_completion_item().label)
|
||||
-- if icon then
|
||||
-- vim_item.kind = icon
|
||||
-- vim_item.kind_hl_group = hl_group
|
||||
-- return vim_item
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- local opts = {
|
||||
-- mode = 'symbol',
|
||||
-- }
|
||||
-- return require('lspkind').cmp_format(opts)(entry, vim_item)
|
||||
-- end
|
||||
-- },
|
||||
formatting = {
|
||||
fields = { "abbr", "menu", "kind" },
|
||||
format = function(entry, vim_item)
|
||||
if vim.tbl_contains({ 'path' }, entry.source.name) then
|
||||
local icon, hl_group = require('nvim-web-devicons').get_icon(entry:get_completion_item().label)
|
||||
if icon then
|
||||
vim_item.kind = icon
|
||||
vim_item.kind_hl_group = hl_group
|
||||
return vim_item
|
||||
end
|
||||
end
|
||||
|
||||
local opts = {
|
||||
mode = 'symbol',
|
||||
}
|
||||
return require('lspkind').cmp_format(opts)(entry, vim_item)
|
||||
end
|
||||
},
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'buffer' },
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@ return {
|
|||
opts = {
|
||||
mappings = {
|
||||
["<leader>rs"] = { vim.lsp.buf.rename, { desc = "Rename symbol" }},
|
||||
gd = { vim.lsp.buf.definition, { desc = "Goto definition" }}
|
||||
["<leader>ca"] = { vim.lsp.buf.code_action, { desc = "Code action" }},
|
||||
gd = { vim.lsp.buf.definition, { desc = "Goto definition" }},
|
||||
gi = { vim.lsp.buf.implementation, { desc = "Goto implementation"}},
|
||||
gr = { vim.lsp.buf.references, { desc = "Goto references"}},
|
||||
},
|
||||
servers = {
|
||||
phpactor = {
|
||||
|
|
@ -19,7 +22,19 @@ return {
|
|||
}
|
||||
}
|
||||
},
|
||||
gopls = {},
|
||||
gopls = {
|
||||
format_on_save = true,
|
||||
settings = {
|
||||
gopls = {
|
||||
analyses = {
|
||||
unusedvariable = true,
|
||||
unusedwrite = true,
|
||||
useany = true
|
||||
},
|
||||
gofumpt = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
lua_ls = {
|
||||
settings = {
|
||||
Lua = {
|
||||
|
|
@ -41,6 +56,7 @@ return {
|
|||
-- Setup Mason to automatically install LSP servers
|
||||
require('mason').setup()
|
||||
require('mason-lspconfig').setup({ automatic_installation = true })
|
||||
local augroup = vim.api.nvim_create_augroup("Lsp", {})
|
||||
local lspconfig = require('lspconfig')
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = false
|
||||
|
|
@ -56,19 +72,49 @@ return {
|
|||
border = "single",
|
||||
})
|
||||
|
||||
local on_attach = function(ev)
|
||||
for bind, settings in pairs(opts.mappings) do
|
||||
vim.keymap.set('n', bind, settings[1], vim.tbl_deep_extend("force", settings[2], { buffer = ev.buf }))
|
||||
end
|
||||
end
|
||||
|
||||
for name, server_opt in pairs(opts.servers) do
|
||||
local on_attach = function(client, bufnr)
|
||||
for bind, settings in pairs(opts.mappings) do
|
||||
vim.keymap.set('n', bind, settings[1], vim.tbl_deep_extend("force", settings[2], { buffer = bufnr }))
|
||||
end
|
||||
|
||||
local settings = vim.tbl_deep_extend("force", server_opt.settings or {}, {
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
|
||||
-- Add format on save if configured and client supports it.
|
||||
if server_opt.format_on_save and client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.format()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function() vim.lsp.buf.document_highlight() end
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("CursorHoldI", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function() vim.lsp.buf.document_highlight() end
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function() vim.lsp.buf.clear_references() end
|
||||
})
|
||||
end
|
||||
|
||||
lspconfig[name].setup({
|
||||
settings = server_opt.settings or {},
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach
|
||||
})
|
||||
lspconfig[name].setup(settings)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ return {
|
|||
"cpp",
|
||||
"ninja",
|
||||
"cmake",
|
||||
"dockerfile",
|
||||
"make",
|
||||
"lua",
|
||||
"vim",
|
||||
|
|
@ -24,6 +25,8 @@ return {
|
|||
"phpdoc",
|
||||
"blade",
|
||||
"go",
|
||||
"gomod",
|
||||
"gosum",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"css",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue