72 lines
2.2 KiB
Lua
72 lines
2.2 KiB
Lua
local lspconfig = require('lspconfig')
|
|
local fidget = require('fidget')
|
|
local nlcmp = require('cmp_nvim_lsp')
|
|
local cmp = require('cmp')
|
|
local map = vim.keymap.set
|
|
--[[
|
|
local jdtls = require('jdtls')
|
|
|
|
jdtls.start_or_attach({
|
|
cmd = { '/home/hex/Documents/dev/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/bin/jdtls' },
|
|
root_dir = vim.fs.dirname(vim.fs.find({ 'gradlew', '.git', 'mvnw' }, { upward = true })[1]),
|
|
})
|
|
--]]
|
|
|
|
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)
|
|
map("n", "<leader>r", "<cmd>Telescope diagnostics bufnr=0<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,
|
|
}
|
|
})
|