feat: config
This commit is contained in:
commit
d47035b8c7
11 changed files with 421 additions and 0 deletions
63
after/plugin/lsp.lua
Normal file
63
after/plugin/lsp.lua
Normal file
|
@ -0,0 +1,63 @@
|
|||
local lspconfig = require('lspconfig')
|
||||
local fidget = require('fidget')
|
||||
local nlcmp = require('cmp_nvim_lsp')
|
||||
local cmp = require('cmp')
|
||||
local map = vim.keymap.set
|
||||
|
||||
vim.opt.signcolumn = 'yes'
|
||||
|
||||
local lc_defaults = lspconfig.util.default_config
|
||||
lc_defaults.capabilities = vim.tbl_deep_extend(
|
||||
'force',
|
||||
lc_defaults.capabilities,
|
||||
nlcmp.default_capabilities()
|
||||
)
|
||||
|
||||
cmp.setup({
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'buffer', keyword_length = 3 }, -- only start autocompleting after a few chars typed
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
-- You need Neovim v0.10 to use vim.snippet
|
||||
vim.snippet.expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<cr>'] = cmp.mapping.confirm({ select = true }),
|
||||
}),
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
}
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
desc = 'LSP actions (apparently)',
|
||||
callback = function(event)
|
||||
fidget.notify("LSP attached to current buffer.", nil, nil)
|
||||
|
||||
local opts = { buffer = event.buf }
|
||||
|
||||
map('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
|
||||
map('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
|
||||
map('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
|
||||
map('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
|
||||
map('n', 'gf', '<cmd>lua vim.lsp.buf.format({async = false, timeout_ms = 10000})<cr>', opts)
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
-- lspconfig.lua_ls.setup({})
|
||||
-- lspconfig.rust_analyzer.setup({})
|
||||
|
||||
require('mason').setup({})
|
||||
require('mason-lspconfig').setup({
|
||||
ensure_installed = { "lua_ls", "gopls", "html", "nim_langserver", "eslint", "clangd" },
|
||||
handlers = {
|
||||
function(svn)
|
||||
lspconfig[svn].setup({})
|
||||
end,
|
||||
}
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue