Clean up LSP configuration for nvim
parent
2f73d1c533
commit
b0451d0a27
|
@ -76,7 +76,6 @@ return require("packer").startup({
|
|||
use("hrsh7th/cmp-path") -- Path source for nvim-cmp
|
||||
use("hrsh7th/cmp-nvim-lua") -- Nvim-Lua source for nvim-cmp
|
||||
use("hrsh7th/nvim-cmp") -- completion integration
|
||||
use("nvim-lua/lsp_extensions.nvim") -- LSP extensions (like closing labels for Dart)
|
||||
use("jose-elias-alvarez/null-ls.nvim") -- Linting and formatting
|
||||
|
||||
-- LSP language specific
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
local null_ls = require("null-ls")
|
||||
local custom_sources = require("esensar.lsp.null-ls_sources")
|
||||
local common_config = require("esensar.lsp.server_config")
|
||||
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
|
@ -50,16 +51,7 @@ null_ls.setup({
|
|||
custom_sources.formatters.gdformat,
|
||||
custom_sources.diagnostics.gdlint,
|
||||
},
|
||||
on_attach = function(client)
|
||||
if client.resolved_capabilities.document_formatting then
|
||||
vim.cmd([[
|
||||
augroup LspFormatting
|
||||
autocmd! * <buffer>
|
||||
autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()
|
||||
augroup END
|
||||
]])
|
||||
end
|
||||
end,
|
||||
on_attach = common_config.on_attach,
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "]w", vim.diagnostic.goto_next)
|
||||
|
|
|
@ -9,15 +9,14 @@ function M.setup()
|
|||
require("jdtls").setup_dap()
|
||||
require("jdtls.setup").add_commands()
|
||||
local on_attach = function(client, bufnr)
|
||||
vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
|
||||
|
||||
common_config.on_attach(client, bufnr)
|
||||
|
||||
local opts = { buffer = bufnr }
|
||||
local code_action_fun = function()
|
||||
require("jdtls").code_action()
|
||||
end
|
||||
vim.keymap.set("n", "<A-CR>", code_action_fun)
|
||||
vim.keymap.set("n", "<Leader>ac", code_action_fun)
|
||||
vim.keymap.set("n", "<A-CR>", code_action_fun, opts)
|
||||
vim.keymap.set("n", "<Leader>ac", code_action_fun, opts)
|
||||
end
|
||||
|
||||
local root_markers = { "gradlew", "pom.xml" }
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
local M = {}
|
||||
|
||||
M.on_attach = function(_, bufnr)
|
||||
vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
|
||||
M.on_attach = function(client, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
|
||||
-- Lsp keymaps
|
||||
local opts = { buffer = bufnr }
|
||||
|
@ -18,6 +18,15 @@ M.on_attach = function(_, bufnr)
|
|||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set("n", "<A-CR>", vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set("n", "<Leader>ac", vim.lsp.buf.code_action, opts)
|
||||
|
||||
if client.resolved_capabilities.document_formatting then
|
||||
vim.cmd([[
|
||||
augroup LspFormatting
|
||||
autocmd! * <buffer>
|
||||
autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()
|
||||
augroup END
|
||||
]])
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Reference in New Issue