mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-21 16:39:04 +02:00
enc: move lsp config to auto-lsp.nvim
This commit is contained in:
parent
5f766a5717
commit
c09e320633
22 changed files with 253 additions and 293 deletions
|
@ -5,6 +5,7 @@
|
||||||
"alpha-nvim": { "branch": "main", "commit": "bf3c8bb8c02ed3d9644cc5bbc48e2bdc39349cd7" },
|
"alpha-nvim": { "branch": "main", "commit": "bf3c8bb8c02ed3d9644cc5bbc48e2bdc39349cd7" },
|
||||||
"auto-conform.nvim": { "branch": "main", "commit": "d04389f955dd0990e85a269b226199f458de32a6" },
|
"auto-conform.nvim": { "branch": "main", "commit": "d04389f955dd0990e85a269b226199f458de32a6" },
|
||||||
"auto-lint.nvim": { "branch": "main", "commit": "aff13cb8eaa055e66e940d43b7d83166397e5413" },
|
"auto-lint.nvim": { "branch": "main", "commit": "aff13cb8eaa055e66e940d43b7d83166397e5413" },
|
||||||
|
"auto-lsp.nvim": { "branch": "main", "commit": "420bd7165d0afd396e05a3ad67ae228c36e2f044" },
|
||||||
"bigfile.nvim": { "branch": "main", "commit": "33eb067e3d7029ac77e081cfe7c45361887a311a" },
|
"bigfile.nvim": { "branch": "main", "commit": "33eb067e3d7029ac77e081cfe7c45361887a311a" },
|
||||||
"bufferline.nvim": { "branch": "main", "commit": "0b2fd861eee7595015b6561dade52fb060be10c4" },
|
"bufferline.nvim": { "branch": "main", "commit": "0b2fd861eee7595015b6561dade52fb060be10c4" },
|
||||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||||
|
@ -40,7 +41,7 @@
|
||||||
"nvim-notify": { "branch": "master", "commit": "fbef5d32be8466dd76544a257d3f3dce20082a07" },
|
"nvim-notify": { "branch": "master", "commit": "fbef5d32be8466dd76544a257d3f3dce20082a07" },
|
||||||
"nvim-scrollview": { "branch": "main", "commit": "bc37a942debe191fffd072f0f1f2ec7c56c54b17" },
|
"nvim-scrollview": { "branch": "main", "commit": "bc37a942debe191fffd072f0f1f2ec7c56c54b17" },
|
||||||
"nvim-tree.lua": { "branch": "master", "commit": "4a9e82d10a3715d0c3845e1d2f66ddfb8b711253" },
|
"nvim-tree.lua": { "branch": "master", "commit": "4a9e82d10a3715d0c3845e1d2f66ddfb8b711253" },
|
||||||
"nvim-treesitter": { "branch": "master", "commit": "68b2bdd99d889e9705f7e90ae64d990f3ff03cf3" },
|
"nvim-treesitter": { "branch": "master", "commit": "a3ca2e60563064cea008555d0b7d031430305b09" },
|
||||||
"nvim-treesitter-textobjects": { "branch": "master", "commit": "0d79d169fcd45a8da464727ac893044728f121d4" },
|
"nvim-treesitter-textobjects": { "branch": "master", "commit": "0d79d169fcd45a8da464727ac893044728f121d4" },
|
||||||
"nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" },
|
"nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" },
|
||||||
"nvim-ts-context-commentstring": { "branch": "main", "commit": "9c74db656c3d0b1c4392fc89a016b1910539e7c0" },
|
"nvim-ts-context-commentstring": { "branch": "main", "commit": "9c74db656c3d0b1c4392fc89a016b1910539e7c0" },
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"williamboman/mason-lspconfig.nvim",
|
"pojokcodeid/auto-lsp.nvim",
|
||||||
event = { "VeryLazy", "BufReadPre", "BufNewFile", "BufRead" },
|
event = { "VeryLazy", "BufReadPre", "BufNewFile", "BufRead" },
|
||||||
dependencies = {
|
dependencies = {
|
||||||
|
{ "williamboman/mason-lspconfig.nvim" },
|
||||||
{
|
{
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
lazy = true,
|
lazy = true,
|
||||||
|
@ -72,66 +73,13 @@ return {
|
||||||
vim.list_extend(opts.ensure_installed, servers)
|
vim.list_extend(opts.ensure_installed, servers)
|
||||||
vim.list_extend(opts.skip_config, unregis_lsp)
|
vim.list_extend(opts.skip_config, unregis_lsp)
|
||||||
opts.automatic_installation = true
|
opts.automatic_installation = true
|
||||||
|
opts.format_on_save = pcode.format_on_save or false -- config format on save none-ls
|
||||||
|
opts.virtual_text = pcode.lsp_virtualtext or false
|
||||||
|
opts.timeout_ms = pcode.format_timeout_ms or 5000
|
||||||
return opts
|
return opts
|
||||||
end,
|
end,
|
||||||
config = function(_, opts)
|
config = function(_, opts)
|
||||||
require("mason-lspconfig").setup(opts)
|
require("auto-lsp").setup(opts)
|
||||||
|
|
||||||
local option = {}
|
|
||||||
require("mason-lspconfig").setup_handlers({
|
|
||||||
function(server_name) -- default handler (optional)
|
|
||||||
local capabilities = require("user.lsp.handlers").capabilities
|
|
||||||
if server_name == "clangd" then
|
|
||||||
capabilities.offsetEncoding = { "utf-16" }
|
|
||||||
end
|
|
||||||
local is_skip = false
|
|
||||||
local my_index = idxOf(opts.skip_config, server_name)
|
|
||||||
if my_index ~= nil then
|
|
||||||
is_skip = true
|
|
||||||
end
|
|
||||||
if not is_skip then
|
|
||||||
option = {
|
|
||||||
on_attach = require("user.lsp.handlers").on_attach,
|
|
||||||
capabilities = capabilities,
|
|
||||||
}
|
|
||||||
|
|
||||||
server_name = vim.split(server_name, "@")[1]
|
|
||||||
|
|
||||||
local require_ok, conf_opts = pcall(require, "user.lsp.settings." .. server_name)
|
|
||||||
if require_ok then
|
|
||||||
option = vim.tbl_deep_extend("force", conf_opts, option)
|
|
||||||
end
|
|
||||||
require("lspconfig")[server_name].setup(option)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
-- ["jdtls"] = function()
|
|
||||||
-- require("lspconfig").jdtls.setup({
|
|
||||||
-- on_attach = require("user.lsp.handlers").on_attach,
|
|
||||||
-- capabilities = require("user.lsp.handlers").capabilities,
|
|
||||||
-- cmd = {
|
|
||||||
-- "jdtls",
|
|
||||||
-- "-configuration",
|
|
||||||
-- vim.fn.expand("$HOME") .. "/.cache/jdtls/config",
|
|
||||||
-- "-data",
|
|
||||||
-- vim.fn.expand("$HOME") .. "/.cache/jdtls/workspace",
|
|
||||||
-- },
|
|
||||||
-- filetypes = { "java" },
|
|
||||||
-- root_dir = require("lspconfig.util").root_pattern(
|
|
||||||
-- -- Single-module projects
|
|
||||||
-- {
|
|
||||||
-- "build.xml", -- Ant
|
|
||||||
-- "pom.xml", -- Maven
|
|
||||||
-- "settings.gradle", -- Gradle
|
|
||||||
-- "settings.gradle.kts", -- Gradle
|
|
||||||
-- },
|
|
||||||
-- -- Multi-module projects
|
|
||||||
-- { "build.gradle", "build.gradle.kts" }
|
|
||||||
-- ) or vim.fn.getcwd(),
|
|
||||||
-- singe_file_support = true,
|
|
||||||
-- })
|
|
||||||
-- end,
|
|
||||||
})
|
|
||||||
require("user.lsp.handlers").setup()
|
|
||||||
end,
|
end,
|
||||||
keys = {
|
keys = {
|
||||||
{ "<leader>l", "", desc = " LSP", mode = "n" },
|
{ "<leader>l", "", desc = " LSP", mode = "n" },
|
||||||
|
|
|
@ -117,7 +117,8 @@ if pcode.active_java_config.active then
|
||||||
},
|
},
|
||||||
settings = opts.settings,
|
settings = opts.settings,
|
||||||
-- enable CMP capabilities
|
-- enable CMP capabilities
|
||||||
capabilities = require("user.lsp.handlers").capabilities or nil,
|
-- capabilities = require("user.lsp.handlers").capabilities or nil,
|
||||||
|
capabilities = require("auto-lsp.lsp.handlers").capabilities or nil,
|
||||||
}, opts.jdtls)
|
}, opts.jdtls)
|
||||||
|
|
||||||
-- Existing server will be reused if the root_dir matches.
|
-- Existing server will be reused if the root_dir matches.
|
||||||
|
@ -138,31 +139,39 @@ if pcode.active_java_config.active then
|
||||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||||
if client and client.name == "jdtls" then
|
if client and client.name == "jdtls" then
|
||||||
local wk = require("which-key")
|
local wk = require("which-key")
|
||||||
wk.register({
|
wk.add({
|
||||||
["<leader>c"] = { name = "+code" },
|
{
|
||||||
["<leader>cx"] = { name = "+extract" },
|
mode = "n",
|
||||||
["<leader>cxv"] = { require("jdtls").extract_variable_all, "Extract Variable" },
|
buffer = args.buf,
|
||||||
["<leader>cxc"] = { require("jdtls").extract_constant, "Extract Constant" },
|
{ "<leader>cx", group = "extract" },
|
||||||
["gs"] = { require("jdtls").super_implementation, "Goto Super" },
|
{ "<leader>cxv", require("jdtls").extract_variable_all, desc = "Extract Variable" },
|
||||||
["<leader>co"] = { require("jdtls").organize_imports, "Organize Imports" },
|
{ "<leader>cxc", require("jdtls").extract_constant, desc = "Extract Constant" },
|
||||||
}, { mode = "n", buffer = args.buf })
|
{ "gs", require("jdtls").super_implementation, desc = "Goto Super" },
|
||||||
wk.register({
|
{ "<leader>co", require("jdtls").organize_imports, desc = "Organize Imports" },
|
||||||
["<leader>c"] = { name = "+code" },
|
},
|
||||||
["<leader>cx"] = { name = "+extract" },
|
})
|
||||||
["<leader>cxm"] = {
|
wk.add({
|
||||||
|
{
|
||||||
|
mode = "v",
|
||||||
|
buffer = args.buf,
|
||||||
|
{ "<leader>cx", group = "extract" },
|
||||||
|
{
|
||||||
|
"<leader>cxm",
|
||||||
[[<ESC><CMD>lua require('jdtls').extract_method(true)<CR>]],
|
[[<ESC><CMD>lua require('jdtls').extract_method(true)<CR>]],
|
||||||
"Extract Method",
|
desc = "Extract Method",
|
||||||
},
|
},
|
||||||
["<leader>cxv"] = {
|
{
|
||||||
|
"<leader>cxv",
|
||||||
[[<ESC><CMD>lua require('jdtls').extract_variable_all(true)<CR>]],
|
[[<ESC><CMD>lua require('jdtls').extract_variable_all(true)<CR>]],
|
||||||
"Extract Variable",
|
desc = "Extract Variable",
|
||||||
},
|
},
|
||||||
["<leader>cxc"] = {
|
{
|
||||||
|
"<leader>cxc",
|
||||||
[[<ESC><CMD>lua require('jdtls').extract_constant(true)<CR>]],
|
[[<ESC><CMD>lua require('jdtls').extract_constant(true)<CR>]],
|
||||||
"Extract Constant",
|
desc = "Extract Constant",
|
||||||
},
|
},
|
||||||
}, { mode = "v", buffer = args.buf })
|
},
|
||||||
|
})
|
||||||
if opts.dap and mason_registry.is_installed("java-debug-adapter") then
|
if opts.dap and mason_registry.is_installed("java-debug-adapter") then
|
||||||
-- custom init for Java debugger
|
-- custom init for Java debugger
|
||||||
require("jdtls").setup_dap(opts.dap)
|
require("jdtls").setup_dap(opts.dap)
|
||||||
|
|
|
@ -52,8 +52,10 @@ if pcode.active_rust_config then
|
||||||
ft = { "rust" },
|
ft = { "rust" },
|
||||||
dependencies = "neovim/nvim-lspconfig",
|
dependencies = "neovim/nvim-lspconfig",
|
||||||
config = function()
|
config = function()
|
||||||
local on_attach = require("user.lsp.handlers").on_attach
|
-- local on_attach = require("user.lsp.handlers").on_attach
|
||||||
local capabilities = require("user.lsp.handlers").capabilities
|
-- local capabilities = require("user.lsp.handlers").capabilities
|
||||||
|
local on_attach = require("auto-lsp.lsp.handlers").on_attach
|
||||||
|
local capabilities = require("auto-lsp.lsp.handlers").capabilities
|
||||||
|
|
||||||
vim.g.rustaceanvim = {
|
vim.g.rustaceanvim = {
|
||||||
server = {
|
server = {
|
||||||
|
|
|
@ -1,34 +1,34 @@
|
||||||
local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer")
|
-- local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer")
|
||||||
if not status_ok then
|
-- if not status_ok then
|
||||||
return
|
-- return
|
||||||
end
|
-- end
|
||||||
|
--
|
||||||
local lspconfig = require("lspconfig")
|
-- local lspconfig = require("lspconfig")
|
||||||
|
--
|
||||||
-- local servers = { "jsonls", "sumneko_lua","html","cssls","tsserver"}
|
-- -- local servers = { "jsonls", "sumneko_lua","html","cssls","tsserver"}
|
||||||
-- local servers = { "jdtls", "yamlls" }
|
-- -- local servers = { "jdtls", "yamlls" }
|
||||||
local servers = {}
|
-- local servers = {}
|
||||||
local installer = pcode.lsp_installer or {}
|
-- local installer = pcode.lsp_installer or {}
|
||||||
for _, client in pairs(installer) do
|
-- for _, client in pairs(installer) do
|
||||||
table.insert(servers, client)
|
-- table.insert(servers, client)
|
||||||
end
|
-- end
|
||||||
|
--
|
||||||
lsp_installer.setup({
|
-- lsp_installer.setup({
|
||||||
ensure_installed = servers,
|
-- ensure_installed = servers,
|
||||||
})
|
|
||||||
|
|
||||||
for _, server in pairs(servers) do
|
|
||||||
local opts = {
|
|
||||||
on_attach = require("user.lsp.handlers").on_attach,
|
|
||||||
capabilities = require("user.lsp.handlers").capabilities,
|
|
||||||
}
|
|
||||||
local has_custom_opts, server_custom_opts = pcall(require, "user.lsp.settings." .. server)
|
|
||||||
if has_custom_opts then
|
|
||||||
opts = vim.tbl_deep_extend("force", opts, server_custom_opts)
|
|
||||||
end
|
|
||||||
lspconfig[server].setup(opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- lspconfig.yamlls.setup({
|
|
||||||
-- fletype = { "yaml", "yaml.docker-compose" },
|
|
||||||
-- })
|
-- })
|
||||||
|
--
|
||||||
|
-- for _, server in pairs(servers) do
|
||||||
|
-- local opts = {
|
||||||
|
-- on_attach = require("user.lsp.handlers").on_attach,
|
||||||
|
-- capabilities = require("user.lsp.handlers").capabilities,
|
||||||
|
-- }
|
||||||
|
-- local has_custom_opts, server_custom_opts = pcall(require, "user.lsp.settings." .. server)
|
||||||
|
-- if has_custom_opts then
|
||||||
|
-- opts = vim.tbl_deep_extend("force", opts, server_custom_opts)
|
||||||
|
-- end
|
||||||
|
-- lspconfig[server].setup(opts)
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- -- lspconfig.yamlls.setup({
|
||||||
|
-- -- fletype = { "yaml", "yaml.docker-compose" },
|
||||||
|
-- -- })
|
||||||
|
|
|
@ -1,147 +1,147 @@
|
||||||
local M = {}
|
-- local M = {}
|
||||||
|
--
|
||||||
local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
-- local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||||
if not status_cmp_ok then
|
-- if not status_cmp_ok then
|
||||||
return
|
-- return
|
||||||
end
|
-- end
|
||||||
|
--
|
||||||
local lspvitualtext = pcode.lsp_virtualtext or false
|
-- local lspvitualtext = pcode.lsp_virtualtext or false
|
||||||
local icons = pcode.icons
|
-- local icons = pcode.icons
|
||||||
|
--
|
||||||
M.capabilities = vim.lsp.protocol.make_client_capabilities()
|
-- M.capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
M.capabilities.textDocument.completion.completionItem.snippetSupport = true
|
-- M.capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||||
M.capabilities = cmp_nvim_lsp.default_capabilities(M.capabilities)
|
-- M.capabilities = cmp_nvim_lsp.default_capabilities(M.capabilities)
|
||||||
|
--
|
||||||
M.setup = function()
|
-- M.setup = function()
|
||||||
local signs = {
|
-- local signs = {
|
||||||
{ name = "DiagnosticSignError", text = icons.diagnostics.Error },
|
-- { name = "DiagnosticSignError", text = icons.diagnostics.Error },
|
||||||
{ name = "DiagnosticSignWarn", text = icons.diagnostics.Warning },
|
-- { name = "DiagnosticSignWarn", text = icons.diagnostics.Warning },
|
||||||
{ name = "DiagnosticSignHint", text = icons.diagnostics.Hint },
|
-- { name = "DiagnosticSignHint", text = icons.diagnostics.Hint },
|
||||||
{ name = "DiagnosticSignInfo", text = icons.diagnostics.Info },
|
-- { name = "DiagnosticSignInfo", text = icons.diagnostics.Info },
|
||||||
}
|
-- }
|
||||||
|
--
|
||||||
for _, sign in ipairs(signs) do
|
-- for _, sign in ipairs(signs) do
|
||||||
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
|
-- vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
|
||||||
end
|
-- end
|
||||||
|
--
|
||||||
local config = {
|
-- local config = {
|
||||||
virtual_text = lspvitualtext, -- disable virtual text
|
-- virtual_text = lspvitualtext, -- disable virtual text
|
||||||
signs = {
|
-- signs = {
|
||||||
active = signs, -- show signs
|
-- active = signs, -- show signs
|
||||||
},
|
-- },
|
||||||
update_in_insert = true,
|
-- update_in_insert = true,
|
||||||
underline = true,
|
-- underline = true,
|
||||||
severity_sort = true,
|
-- severity_sort = true,
|
||||||
float = {
|
-- float = {
|
||||||
focusable = true,
|
-- focusable = true,
|
||||||
style = "minimal",
|
-- style = "minimal",
|
||||||
border = "rounded",
|
-- border = "rounded",
|
||||||
source = "always",
|
-- source = "always",
|
||||||
header = "",
|
-- header = "",
|
||||||
prefix = "",
|
-- prefix = "",
|
||||||
},
|
-- },
|
||||||
}
|
-- }
|
||||||
|
--
|
||||||
vim.diagnostic.config(config)
|
-- vim.diagnostic.config(config)
|
||||||
|
--
|
||||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
|
-- vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||||
border = "rounded",
|
-- border = "rounded",
|
||||||
})
|
-- })
|
||||||
|
--
|
||||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
|
-- vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
|
||||||
border = "rounded",
|
-- border = "rounded",
|
||||||
})
|
-- })
|
||||||
end
|
-- end
|
||||||
|
--
|
||||||
local function attach_navic(client, bufnr)
|
-- local function attach_navic(client, bufnr)
|
||||||
vim.g.navic_silence = true
|
-- vim.g.navic_silence = true
|
||||||
local status_ok, navic = pcall(require, "nvim-navic")
|
-- local status_ok, navic = pcall(require, "nvim-navic")
|
||||||
if not status_ok then
|
-- if not status_ok then
|
||||||
return
|
-- return
|
||||||
end
|
-- end
|
||||||
navic.attach(client, bufnr)
|
-- navic.attach(client, bufnr)
|
||||||
end
|
-- end
|
||||||
|
--
|
||||||
function FORMAT_FILTER(client)
|
-- function FORMAT_FILTER(client)
|
||||||
local filetype = vim.bo.filetype
|
-- local filetype = vim.bo.filetype
|
||||||
local n = require("null-ls")
|
-- local n = require("null-ls")
|
||||||
local s = require("null-ls.sources")
|
-- local s = require("null-ls.sources")
|
||||||
local method = n.methods.FORMATTING
|
-- local method = n.methods.FORMATTING
|
||||||
local available_formatters = s.get_available(filetype, method)
|
-- local available_formatters = s.get_available(filetype, method)
|
||||||
|
--
|
||||||
if #available_formatters > 0 then
|
-- if #available_formatters > 0 then
|
||||||
return client.name == "null-ls"
|
-- return client.name == "null-ls"
|
||||||
elseif client.supports_method("textDocument/formatting") then
|
-- elseif client.supports_method("textDocument/formatting") then
|
||||||
return true
|
-- return true
|
||||||
else
|
-- else
|
||||||
return false
|
-- return false
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
|
--
|
||||||
-- stylua: ignore
|
-- -- stylua: ignore
|
||||||
local function lsp_keymaps(bufnr, on_save)
|
-- local function lsp_keymaps(bufnr, on_save)
|
||||||
local opts = { noremap = true, silent = true }
|
-- local opts = { noremap = true, silent = true }
|
||||||
local keymap = vim.api.nvim_buf_set_keymap
|
-- local keymap = vim.api.nvim_buf_set_keymap
|
||||||
keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
-- keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
||||||
keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
-- keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||||
keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
-- keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||||
keymap(bufnr, "n", "gI", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
-- keymap(bufnr, "n", "gI", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||||
keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
-- keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
||||||
keymap(bufnr, "n", "gl", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
|
-- keymap(bufnr, "n", "gl", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
|
||||||
keymap(bufnr, "n", "<leader>lf", "<cmd>lua vim.lsp.buf.format{ async = true }<cr>", opts)
|
-- keymap(bufnr, "n", "<leader>lf", "<cmd>lua vim.lsp.buf.format{ async = true }<cr>", opts)
|
||||||
keymap(bufnr, "n", "<leader>li", "<cmd>LspInfo<cr>", opts)
|
-- keymap(bufnr, "n", "<leader>li", "<cmd>LspInfo<cr>", opts)
|
||||||
keymap(bufnr, "n", "<leader>lI", "<cmd>Mason<cr>", opts)
|
-- keymap(bufnr, "n", "<leader>lI", "<cmd>Mason<cr>", opts)
|
||||||
keymap(bufnr, "n", "<leader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", opts)
|
-- keymap(bufnr, "n", "<leader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", opts)
|
||||||
keymap(bufnr, "n", "<leader>lj", "<cmd>lua vim.diagnostic.goto_next({buffer=0})<cr>", opts)
|
-- keymap(bufnr, "n", "<leader>lj", "<cmd>lua vim.diagnostic.goto_next({buffer=0})<cr>", opts)
|
||||||
keymap(bufnr, "n", "<leader>lk", "<cmd>lua vim.diagnostic.goto_prev({buffer=0})<cr>", opts)
|
-- keymap(bufnr, "n", "<leader>lk", "<cmd>lua vim.diagnostic.goto_prev({buffer=0})<cr>", opts)
|
||||||
keymap(bufnr, "n", "<leader>lr", "<cmd>lua vim.lsp.buf.rename()<cr>", opts)
|
-- keymap(bufnr, "n", "<leader>lr", "<cmd>lua vim.lsp.buf.rename()<cr>", opts)
|
||||||
keymap(bufnr, "n", "<leader>ls", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
-- keymap(bufnr, "n", "<leader>ls", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||||
keymap(bufnr, "n", "<leader>lq", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
|
-- keymap(bufnr, "n", "<leader>lq", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
|
||||||
if on_save then
|
-- if on_save then
|
||||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
-- local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
-- vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
-- vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
group = augroup,
|
-- group = augroup,
|
||||||
buffer = bufnr,
|
-- buffer = bufnr,
|
||||||
callback = function()
|
-- callback = function()
|
||||||
vim.lsp.buf.format({ bufnr = bufnr, timeout_ms = pcode.format_timeout_ms or 5000, filter = FORMAT_FILTER })
|
-- vim.lsp.buf.format({ bufnr = bufnr, timeout_ms = pcode.format_timeout_ms or 5000, filter = FORMAT_FILTER })
|
||||||
end,
|
-- end,
|
||||||
})
|
-- })
|
||||||
else
|
-- else
|
||||||
vim.schedule(function()
|
-- vim.schedule(function()
|
||||||
pcall(function()
|
-- pcall(function()
|
||||||
vim.api.nvim_clear_autocmds({ group = "LspFormatting" })
|
-- vim.api.nvim_clear_autocmds({ group = "LspFormatting" })
|
||||||
end)
|
-- end)
|
||||||
end)
|
-- end)
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
M.on_attach = function(client, bufnr)
|
-- M.on_attach = function(client, bufnr)
|
||||||
attach_navic(client, bufnr)
|
-- attach_navic(client, bufnr)
|
||||||
if client.name == "tsserver" then
|
-- if client.name == "tsserver" then
|
||||||
client.server_capabilities.documentFormattingProvider = false
|
-- client.server_capabilities.documentFormattingProvider = false
|
||||||
end
|
-- end
|
||||||
|
--
|
||||||
if client.name == "lua_ls" then
|
-- if client.name == "lua_ls" then
|
||||||
client.server_capabilities.documentFormattingProvider = false
|
-- client.server_capabilities.documentFormattingProvider = false
|
||||||
end
|
-- end
|
||||||
|
--
|
||||||
if client.supports_method("textDocument/inlayHint") then
|
-- if client.supports_method("textDocument/inlayHint") then
|
||||||
-- vim.lsp.inlay_hint.enable(bufnr, true)
|
-- -- vim.lsp.inlay_hint.enable(bufnr, true)
|
||||||
vim.lsp.inlay_hint.enable(true)
|
-- vim.lsp.inlay_hint.enable(true)
|
||||||
end
|
-- end
|
||||||
|
--
|
||||||
local on_save = pcode.format_on_save or false
|
-- local on_save = pcode.format_on_save or false
|
||||||
-- disable if conform active
|
-- -- disable if conform active
|
||||||
local status, _ = pcall(require, "conform")
|
-- local status, _ = pcall(require, "conform")
|
||||||
if status then
|
-- if status then
|
||||||
on_save = false
|
-- on_save = false
|
||||||
end
|
-- end
|
||||||
lsp_keymaps(bufnr, on_save)
|
-- lsp_keymaps(bufnr, on_save)
|
||||||
local status_ok, illuminate = pcall(require, "illuminate")
|
-- local status_ok, illuminate = pcall(require, "illuminate")
|
||||||
if not status_ok then
|
-- if not status_ok then
|
||||||
return
|
-- return
|
||||||
end
|
-- end
|
||||||
illuminate.on_attach(client)
|
-- illuminate.on_attach(client)
|
||||||
end
|
-- end
|
||||||
|
--
|
||||||
return M
|
-- return M
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue