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-path") -- Path source for nvim-cmp
|
||||||
use("hrsh7th/cmp-nvim-lua") -- Nvim-Lua source for nvim-cmp
|
use("hrsh7th/cmp-nvim-lua") -- Nvim-Lua source for nvim-cmp
|
||||||
use("hrsh7th/nvim-cmp") -- completion integration
|
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
|
use("jose-elias-alvarez/null-ls.nvim") -- Linting and formatting
|
||||||
|
|
||||||
-- LSP language specific
|
-- LSP language specific
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
local null_ls = require("null-ls")
|
local null_ls = require("null-ls")
|
||||||
local custom_sources = require("esensar.lsp.null-ls_sources")
|
local custom_sources = require("esensar.lsp.null-ls_sources")
|
||||||
|
local common_config = require("esensar.lsp.server_config")
|
||||||
|
|
||||||
null_ls.setup({
|
null_ls.setup({
|
||||||
sources = {
|
sources = {
|
||||||
|
@ -50,16 +51,7 @@ null_ls.setup({
|
||||||
custom_sources.formatters.gdformat,
|
custom_sources.formatters.gdformat,
|
||||||
custom_sources.diagnostics.gdlint,
|
custom_sources.diagnostics.gdlint,
|
||||||
},
|
},
|
||||||
on_attach = function(client)
|
on_attach = common_config.on_attach,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.keymap.set("n", "]w", vim.diagnostic.goto_next)
|
vim.keymap.set("n", "]w", vim.diagnostic.goto_next)
|
||||||
|
|
|
@ -9,15 +9,14 @@ function M.setup()
|
||||||
require("jdtls").setup_dap()
|
require("jdtls").setup_dap()
|
||||||
require("jdtls.setup").add_commands()
|
require("jdtls.setup").add_commands()
|
||||||
local on_attach = function(client, bufnr)
|
local on_attach = function(client, bufnr)
|
||||||
vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
|
|
||||||
|
|
||||||
common_config.on_attach(client, bufnr)
|
common_config.on_attach(client, bufnr)
|
||||||
|
|
||||||
|
local opts = { buffer = bufnr }
|
||||||
local code_action_fun = function()
|
local code_action_fun = function()
|
||||||
require("jdtls").code_action()
|
require("jdtls").code_action()
|
||||||
end
|
end
|
||||||
vim.keymap.set("n", "<A-CR>", code_action_fun)
|
vim.keymap.set("n", "<A-CR>", code_action_fun, opts)
|
||||||
vim.keymap.set("n", "<Leader>ac", code_action_fun)
|
vim.keymap.set("n", "<Leader>ac", code_action_fun, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
local root_markers = { "gradlew", "pom.xml" }
|
local root_markers = { "gradlew", "pom.xml" }
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.on_attach = function(_, bufnr)
|
M.on_attach = function(client, bufnr)
|
||||||
vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
|
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||||
|
|
||||||
-- Lsp keymaps
|
-- Lsp keymaps
|
||||||
local opts = { buffer = bufnr }
|
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", "K", vim.lsp.buf.hover, opts)
|
||||||
vim.keymap.set("n", "<A-CR>", vim.lsp.buf.code_action, 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)
|
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
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Reference in New Issue