summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/lsp
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/lsp')
-rw-r--r--.config/nvim/lua/lsp/config.lua2
-rw-r--r--.config/nvim/lua/lsp/handlers.lua12
-rw-r--r--.config/nvim/lua/lsp/init.lua18
-rw-r--r--.config/nvim/lua/lsp/null-ls/formatters.lua29
-rw-r--r--.config/nvim/lua/lsp/null-ls/init.lua2
-rw-r--r--.config/nvim/lua/lsp/null-ls/linters.lua23
-rw-r--r--.config/nvim/lua/lsp/null-ls/services.lua14
7 files changed, 59 insertions, 41 deletions
diff --git a/.config/nvim/lua/lsp/config.lua b/.config/nvim/lua/lsp/config.lua
index 673f924..61428aa 100644
--- a/.config/nvim/lua/lsp/config.lua
+++ b/.config/nvim/lua/lsp/config.lua
@@ -40,6 +40,7 @@ return {
},
null_ls = {
setup = {},
+ config = {},
},
override = {
"angularls",
@@ -55,6 +56,7 @@ return {
"phpactor",
"pylsp",
"rome",
+ "sorbet",
"sqlls",
"sqls",
"stylelint_lsp",
diff --git a/.config/nvim/lua/lsp/handlers.lua b/.config/nvim/lua/lsp/handlers.lua
index 01666be..fcf7630 100644
--- a/.config/nvim/lua/lsp/handlers.lua
+++ b/.config/nvim/lua/lsp/handlers.lua
@@ -37,18 +37,6 @@ function M.setup()
return
end
- local sign_names = {
- "DiagnosticSignError",
- "DiagnosticSignWarn",
- "DiagnosticSignInfo",
- "DiagnosticSignHint",
- }
- for i, sign in ipairs(options.lsp.diagnostics.signs.values) do
- vim.fn.sign_define(
- sign_names[i],
- { texthl = sign_names[i], text = sign.text, numhl = "" }
- )
- end
vim_diag.show(namespace, bufnr, diagnostics, config)
else
vim.lsp.diagnostic.save(diagnostics, bufnr, ctx.client_id)
diff --git a/.config/nvim/lua/lsp/init.lua b/.config/nvim/lua/lsp/init.lua
index f92ecd3..9cb3e78 100644
--- a/.config/nvim/lua/lsp/init.lua
+++ b/.config/nvim/lua/lsp/init.lua
@@ -150,6 +150,13 @@ function M.get_common_opts()
}
end
+local LSP_DEPRECATED_SIGN_MAP = {
+ ["LspDiagnosticsSignError"] = "DiagnosticSignError",
+ ["LspDiagnosticsSignWarning"] = "DiagnosticSignWarn",
+ ["LspDiagnosticsSignHint"] = "DiagnosticSignHint",
+ ["LspDiagnosticsSignInformation"] = "DiagnosticSignInfo",
+}
+
function M.setup()
Log:debug "Setting up LSP support"
@@ -158,7 +165,16 @@ function M.setup()
return
end
+ local is_neovim_nightly = vim.fn.has "nvim-0.5.1" > 0
+
for _, sign in ipairs(options.lsp.diagnostics.signs.values) do
+ local lsp_sign_name = LSP_DEPRECATED_SIGN_MAP[sign.name]
+ if is_neovim_nightly and lsp_sign_name then
+ vim.fn.sign_define(
+ lsp_sign_name,
+ { texthl = lsp_sign_name, text = sign.text, numhl = lsp_sign_name }
+ )
+ end
vim.fn.sign_define(
sign.name,
{ texthl = sign.name, text = sign.text, numhl = sign.name }
@@ -176,7 +192,7 @@ function M.setup()
require("lsp.null-ls").setup()
- require("utils").toggle_autoformat()
+ require("core.autocmds").configure_format_on_save()
end
return M
diff --git a/.config/nvim/lua/lsp/null-ls/formatters.lua b/.config/nvim/lua/lsp/null-ls/formatters.lua
index 991f613..7bd4dc4 100644
--- a/.config/nvim/lua/lsp/null-ls/formatters.lua
+++ b/.config/nvim/lua/lsp/null-ls/formatters.lua
@@ -4,6 +4,8 @@ local null_ls = require "null-ls"
local services = require "lsp.null-ls.services"
local Log = require "core.log"
+local is_registered = require("null-ls.sources").is_registered
+
function M.list_registered_providers(filetype)
local null_ls_methods = require "null-ls.methods"
local formatter_method = null_ls_methods.internal["FORMATTING"]
@@ -32,24 +34,29 @@ function M.list_configured(formatter_configs)
local formatters, errors = {}, {}
for _, fmt_config in ipairs(formatter_configs) do
- local formatter_name = fmt_config.exe:gsub("-", "_")
- local formatter = null_ls.builtins.formatting[formatter_name]
+ local name = fmt_config.exe:gsub("-", "_")
+ local formatter = null_ls.builtins.formatting[name]
if not formatter then
Log:error("Not a valid formatter: " .. fmt_config.exe)
- errors[fmt_config.exe] = {} -- Add data here when necessary
+ errors[name] = {} -- Add data here when necessary
+ elseif is_registered(fmt_config.exe) then
+ Log:trace "Skipping registering the source more than once"
else
local formatter_cmd = services.find_command(formatter._opts.command)
if not formatter_cmd then
Log:warn("Not found: " .. formatter._opts.command)
- errors[fmt_config.exe] = {} -- Add data here when necessary
+ errors[name] = {} -- Add data here when necessary
else
Log:debug("Using formatter: " .. formatter_cmd)
- formatters[fmt_config.exe] = formatter.with {
- command = formatter_cmd,
- extra_args = fmt_config.args,
- filetypes = fmt_config.filetypes,
- }
+ table.insert(
+ formatters,
+ formatter.with {
+ command = formatter_cmd,
+ extra_args = fmt_config.args,
+ filetypes = fmt_config.filetypes,
+ }
+ )
end
end
end
@@ -62,8 +69,8 @@ function M.setup(formatter_configs)
return
end
- local formatters_by_ft = M.list_configured(formatter_configs)
- null_ls.register { sources = formatters_by_ft.supported }
+ local formatters = M.list_configured(formatter_configs)
+ null_ls.register { sources = formatters.supported }
end
return M
diff --git a/.config/nvim/lua/lsp/null-ls/init.lua b/.config/nvim/lua/lsp/null-ls/init.lua
index 9560240..adbc5b2 100644
--- a/.config/nvim/lua/lsp/null-ls/init.lua
+++ b/.config/nvim/lua/lsp/null-ls/init.lua
@@ -9,7 +9,7 @@ function M:setup()
return
end
- null_ls.config()
+ null_ls.config(options.lsp.null_ls.config)
local default_opts = require("lsp").get_common_opts()
if vim.tbl_isempty(options.lsp.null_ls.setup or {}) then
diff --git a/.config/nvim/lua/lsp/null-ls/linters.lua b/.config/nvim/lua/lsp/null-ls/linters.lua
index 85555ba..0d34365 100644
--- a/.config/nvim/lua/lsp/null-ls/linters.lua
+++ b/.config/nvim/lua/lsp/null-ls/linters.lua
@@ -4,6 +4,8 @@ local null_ls = require "null-ls"
local services = require "lsp.null-ls.services"
local Log = require "core.log"
+local is_registered = require("null-ls.sources").is_registered
+
function M.list_registered_providers(filetype)
local null_ls_methods = require "null-ls.methods"
local linter_method = null_ls_methods.internal["DIAGNOSTICS"]
@@ -32,24 +34,29 @@ function M.list_configured(linter_configs)
local linters, errors = {}, {}
for _, lnt_config in pairs(linter_configs) do
- local linter_name = lnt_config.exe:gsub("-", "_")
- local linter = null_ls.builtins.diagnostics[linter_name]
+ local name = lnt_config.exe:gsub("-", "_")
+ local linter = null_ls.builtins.diagnostics[name]
if not linter then
Log:error("Not a valid linter: " .. lnt_config.exe)
errors[lnt_config.exe] = {} -- Add data here when necessary
+ elseif is_registered(lnt_config.exe) then
+ Log:trace "Skipping registering the source more than once"
else
local linter_cmd = services.find_command(linter._opts.command)
if not linter_cmd then
Log:warn("Not found: " .. linter._opts.command)
- errors[lnt_config.exe] = {} -- Add data here when necessary
+ errors[name] = {} -- Add data here when necessary
else
Log:debug("Using linter: " .. linter_cmd)
- linters[lnt_config.exe] = linter.with {
- command = linter_cmd,
- extra_args = lnt_config.args,
- filetypes = lnt_config.filetypes,
- }
+ table.insert(
+ linters,
+ linter.with {
+ command = linter_cmd,
+ extra_args = lnt_config.args,
+ filetypes = lnt_config.filetypes,
+ }
+ )
end
end
end
diff --git a/.config/nvim/lua/lsp/null-ls/services.lua b/.config/nvim/lua/lsp/null-ls/services.lua
index ef9e7d2..6a52520 100644
--- a/.config/nvim/lua/lsp/null-ls/services.lua
+++ b/.config/nvim/lua/lsp/null-ls/services.lua
@@ -46,15 +46,13 @@ function M.find_command(command)
end
function M.list_registered_providers_names(filetype)
- local u = require "null-ls.utils"
- local c = require "null-ls.config"
+ local s = require "null-ls.sources"
+ local available_sources = s.get_available(filetype)
local registered = {}
- for method, source in pairs(c.get()._methods) do
- for name, filetypes in pairs(source) do
- if u.filetype_matches(filetypes, filetype) then
- registered[method] = registered[method] or {}
- table.insert(registered[method], name)
- end
+ for _, source in ipairs(available_sources) do
+ for method in pairs(source.methods) do
+ registered[method] = registered[method] or {}
+ table.insert(registered[method], source.name)
end
end
return registered