mirror of
https://github.com/ViViDboarder/vim-settings.git
synced 2024-12-22 13:17:38 +00:00
Refactor null-ls and remove conflicted formatting
This commit is contained in:
parent
64583bf41d
commit
90581a444b
@ -45,71 +45,81 @@ function M.config_lsp_ui()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function default_attach(client, bufnr)
|
local function get_default_attach(override_capabilities)
|
||||||
local function buf_set_keymap(...)
|
return function(client, bufnr)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
-- Allow overriding capabilities to avoid duplicate lsps with capabilities
|
||||||
end
|
if override_capabilities ~= nil then
|
||||||
local function buf_set_option(...)
|
client.resolved_capabilities = vim.tbl_extend(
|
||||||
vim.api.nvim_buf_set_option(bufnr, ...)
|
"force",
|
||||||
end
|
client.resolved_capabilities,
|
||||||
|
override_capabilities or {}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
-- Set built in features to use lsp functions
|
local function buf_set_keymap(...)
|
||||||
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
|
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||||
if client.resolved_capabilities.goto_definition then
|
end
|
||||||
buf_set_option("tagfunc", "v:lua.vim.lsp.tagfunc")
|
local function buf_set_option(...)
|
||||||
end
|
vim.api.nvim_buf_set_option(bufnr, ...)
|
||||||
if client.resolved_capabilities.document_formatting then
|
end
|
||||||
buf_set_option("formatexpr", "v:lua.vim.lsp.formatexpr()")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Mappings
|
-- Set built in features to use lsp functions
|
||||||
-- TODO: Maybe prefix all of these for easier discovery
|
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||||
local opts = { noremap = true, silent = true }
|
if client.resolved_capabilities.goto_definition then
|
||||||
|
buf_set_option("tagfunc", "v:lua.vim.lsp.tagfunc")
|
||||||
|
end
|
||||||
|
if client.resolved_capabilities.document_formatting then
|
||||||
|
buf_set_option("formatexpr", "v:lua.vim.lsp.formatexpr()")
|
||||||
|
end
|
||||||
|
|
||||||
local lsp_keymap = utils.keymap_group("n", "<leader>l", opts, bufnr)
|
-- Mappings
|
||||||
lsp_keymap("h", "<cmd>lua vim.lsp.buf.hover()<CR>")
|
-- TODO: Maybe prefix all of these for easier discovery
|
||||||
lsp_keymap("r", "<cmd>lua vim.lsp.buf.rename()<CR>")
|
local opts = { noremap = true, silent = true }
|
||||||
lsp_keymap("e", "<cmd>lua vim.lsp.diagnostics.show_line_diagnostics()<CR>")
|
|
||||||
|
|
||||||
buf_set_keymap("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
local lsp_keymap = utils.keymap_group("n", "<leader>l", opts, bufnr)
|
||||||
buf_set_keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
lsp_keymap("h", "<cmd>lua vim.lsp.buf.hover()<CR>")
|
||||||
buf_set_keymap("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
lsp_keymap("r", "<cmd>lua vim.lsp.buf.rename()<CR>")
|
||||||
buf_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
lsp_keymap("e", "<cmd>lua vim.lsp.diagnostics.show_line_diagnostics()<CR>")
|
||||||
buf_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<leader>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<leader>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<leader>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<leader>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<leader>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<leader>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts)
|
|
||||||
|
|
||||||
-- Open diagnostic on hold
|
buf_set_keymap("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
||||||
if vim["diagnostic"] ~= nil then
|
buf_set_keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||||
vim.cmd([[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]])
|
buf_set_keymap("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||||
end
|
buf_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||||
|
buf_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||||
|
buf_set_keymap("n", "<leader>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts)
|
||||||
|
buf_set_keymap("n", "<leader>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts)
|
||||||
|
buf_set_keymap("n", "<leader>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts)
|
||||||
|
buf_set_keymap("n", "<leader>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
||||||
|
buf_set_keymap("n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||||
|
buf_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
||||||
|
buf_set_keymap("n", "<leader>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts)
|
||||||
|
buf_set_keymap("n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", opts)
|
||||||
|
buf_set_keymap("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", opts)
|
||||||
|
buf_set_keymap("n", "<leader>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts)
|
||||||
|
|
||||||
-- Set some keybinds conditional on server capabilities
|
-- Open diagnostic on hold
|
||||||
if client.resolved_capabilities.document_formatting then
|
if vim["diagnostic"] ~= nil then
|
||||||
buf_set_keymap("n", "<leader>lf", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
vim.cmd([[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]])
|
||||||
vim.cmd([[
|
end
|
||||||
|
|
||||||
|
-- Set some keybinds conditional on server capabilities
|
||||||
|
if client.resolved_capabilities.document_formatting then
|
||||||
|
buf_set_keymap("n", "<leader>lf", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
||||||
|
vim.cmd([[
|
||||||
augroup lsp_format
|
augroup lsp_format
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufWritePre *.rs,*.go,*.sh lua vim.lsp.buf.formatting_sync(nil, 1000)
|
autocmd BufWritePre *.rs,*.go,*.sh lua vim.lsp.buf.formatting_sync(nil, 1000)
|
||||||
" autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync(nil, 1000)
|
" autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync(nil, 1000)
|
||||||
augroup END
|
augroup END
|
||||||
]])
|
]])
|
||||||
end
|
end
|
||||||
if client.resolved_capabilities.document_range_formatting then
|
if client.resolved_capabilities.document_range_formatting then
|
||||||
buf_set_keymap("n", "<leader>lfr", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts)
|
buf_set_keymap("n", "<leader>lfr", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set autocommands conditional on server_capabilities
|
-- Set autocommands conditional on server_capabilities
|
||||||
if client.resolved_capabilities.document_highlight then
|
if client.resolved_capabilities.document_highlight then
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
:hi LspReferenceRead cterm=bold ctermbg=red guibg=LightYellow
|
:hi LspReferenceRead cterm=bold ctermbg=red guibg=LightYellow
|
||||||
:hi LspReferenceText cterm=bold ctermbg=red guibg=LightYellow
|
:hi LspReferenceText cterm=bold ctermbg=red guibg=LightYellow
|
||||||
:hi LspReferenceWrite cterm=bold ctermbg=red guibg=LightYellow
|
:hi LspReferenceWrite cterm=bold ctermbg=red guibg=LightYellow
|
||||||
@ -119,24 +129,25 @@ local function default_attach(client, bufnr)
|
|||||||
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
||||||
augroup END
|
augroup END
|
||||||
]])
|
]])
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Some override some fuzzy finder bindings to use lsp sources
|
-- Some override some fuzzy finder bindings to use lsp sources
|
||||||
if utils.try_require("telescope.nvim") ~= nil then
|
if utils.try_require("telescope.nvim") ~= nil then
|
||||||
buf_set_keymap("n", "<leader>t", "<cmd>Telescope lsp_document_symbols<CR>", opts)
|
buf_set_keymap("n", "<leader>t", "<cmd>Telescope lsp_document_symbols<CR>", opts)
|
||||||
buf_set_keymap("n", "<leader>ft", "<cmd>Telescope lsp_dynamic_workspace_symbols<CR>", opts)
|
buf_set_keymap("n", "<leader>ft", "<cmd>Telescope lsp_dynamic_workspace_symbols<CR>", opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Use LspSaga features, if possible
|
-- Use LspSaga features, if possible
|
||||||
if utils.is_plugin_loaded("lspsaga.nvim") then
|
if utils.is_plugin_loaded("lspsaga.nvim") then
|
||||||
buf_set_keymap("n", "K", "<Cmd>lua require('lspsaga.hover').render_hover_doc()<CR>", opts)
|
buf_set_keymap("n", "K", "<Cmd>lua require('lspsaga.hover').render_hover_doc()<CR>", opts)
|
||||||
buf_set_keymap("n", "<leader>rn", "<cmd>lua require('lspsaga.rename').rename()<CR>", opts)
|
buf_set_keymap("n", "<leader>rn", "<cmd>lua require('lspsaga.rename').rename()<CR>", opts)
|
||||||
buf_set_keymap("n", "<leader>e", "<cmd>lua require('lspsaga.diagnostic').show_line_diagnostics()<CR>", opts)
|
buf_set_keymap("n", "<leader>e", "<cmd>lua require('lspsaga.diagnostic').show_line_diagnostics()<CR>", opts)
|
||||||
buf_set_keymap("n", "[d", "<cmd>lua require('lspsaga.diagnostic').lsp_jump_diagnostic_prev()<CR>", opts)
|
buf_set_keymap("n", "[d", "<cmd>lua require('lspsaga.diagnostic').lsp_jump_diagnostic_prev()<CR>", opts)
|
||||||
buf_set_keymap("n", "]d", "<cmd>lua require('lspsaga.diagnostic').lsp_jump_diagnostic_next()<CR>", opts)
|
buf_set_keymap("n", "]d", "<cmd>lua require('lspsaga.diagnostic').lsp_jump_diagnostic_next()<CR>", opts)
|
||||||
buf_set_keymap("n", "<C-k>", "<cmd>lua require('lspsaga.signaturehelp').signature_help()<CR>", opts)
|
buf_set_keymap("n", "<C-k>", "<cmd>lua require('lspsaga.signaturehelp').signature_help()<CR>", opts)
|
||||||
-- Code actions
|
-- Code actions
|
||||||
buf_set_keymap("n", "<leader>ca", "<cmd>lua require('lspsaga.codeaction').code_action()<CR>", opts)
|
buf_set_keymap("n", "<leader>ca", "<cmd>lua require('lspsaga.codeaction').code_action()<CR>", opts)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -153,13 +164,19 @@ function M.config_lsp()
|
|||||||
utils.try_require("lspconfig", function(lsp_config)
|
utils.try_require("lspconfig", function(lsp_config)
|
||||||
local capabilities = merged_capabilities()
|
local capabilities = merged_capabilities()
|
||||||
|
|
||||||
|
-- Config null-ls
|
||||||
|
require("plugins.null-ls").configure({ capabilities = capabilities, on_attach = get_default_attach() })
|
||||||
|
|
||||||
|
-- Attach options to disable formatting
|
||||||
|
local no_format = { document_formatting = false, document_range_formatting = false }
|
||||||
|
|
||||||
-- Configure each server
|
-- Configure each server
|
||||||
lsp_config.bashls.setup({ capabilities = capabilities, on_attach = default_attach })
|
lsp_config.bashls.setup({ capabilities = capabilities, on_attach = get_default_attach() })
|
||||||
lsp_config.gopls.setup({ capabilities = capabilities, on_attach = default_attach })
|
lsp_config.gopls.setup({ capabilities = capabilities, on_attach = get_default_attach(no_format) })
|
||||||
lsp_config.pyright.setup({ capabilities = capabilities, on_attach = default_attach })
|
lsp_config.pyright.setup({ capabilities = capabilities, on_attach = get_default_attach(no_format) })
|
||||||
lsp_config.rls.setup({
|
lsp_config.rls.setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = default_attach,
|
on_attach = get_default_attach(no_format),
|
||||||
settings = {
|
settings = {
|
||||||
rust = {
|
rust = {
|
||||||
build_on_save = false,
|
build_on_save = false,
|
||||||
@ -187,87 +204,13 @@ function M.config_lsp_saga()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.config_null_ls()
|
|
||||||
utils.try_require("null-ls", function(null_ls)
|
|
||||||
local helpers = require("null-ls.helpers")
|
|
||||||
local alex_lint = {
|
|
||||||
name = "alex",
|
|
||||||
method = null_ls.methods.DIAGNOSTICS,
|
|
||||||
filetypes = { "markdown" },
|
|
||||||
generator = null_ls.generator({
|
|
||||||
command = "alex",
|
|
||||||
args = { "--stdin", "--quiet" },
|
|
||||||
to_stdin = true,
|
|
||||||
from_stderr = true,
|
|
||||||
format = "line",
|
|
||||||
check_exit_code = function(code)
|
|
||||||
return code <= 1
|
|
||||||
end,
|
|
||||||
on_output = helpers.diagnostics.from_patterns({
|
|
||||||
{
|
|
||||||
pattern = [[ *(%d+):(%d+)-(%d+):(%d+) *(%w+) *(.+) +[%w]+ +([-%l]+)]],
|
|
||||||
groups = { "row", "col", "end_row", "end_col", "severity", "message", "code" },
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
|
|
||||||
local sources = {
|
|
||||||
-- Generic
|
|
||||||
null_ls.builtins.formatting.prettier,
|
|
||||||
null_ls.builtins.formatting.trim_whitespace,
|
|
||||||
null_ls.builtins.formatting.trim_newlines,
|
|
||||||
-- Fish
|
|
||||||
null_ls.builtins.formatting.fish_indent,
|
|
||||||
-- Python
|
|
||||||
null_ls.builtins.formatting.reorder_python_imports,
|
|
||||||
null_ls.builtins.formatting.black,
|
|
||||||
null_ls.builtins.diagnostics.mypy,
|
|
||||||
-- Go
|
|
||||||
null_ls.builtins.diagnostics.golangci_lint,
|
|
||||||
-- Text
|
|
||||||
null_ls.builtins.diagnostics.proselint,
|
|
||||||
-- null_ls.builtins.diagnostics.write_good,
|
|
||||||
null_ls.builtins.code_actions.proselint,
|
|
||||||
alex_lint,
|
|
||||||
-- Ansible
|
|
||||||
null_ls.builtins.diagnostics.ansiblelint,
|
|
||||||
-- Shell
|
|
||||||
null_ls.builtins.diagnostics.shellcheck,
|
|
||||||
-- Rust
|
|
||||||
-- null_ls.builtins.formatting.rustfmt,
|
|
||||||
-- Lua
|
|
||||||
null_ls.builtins.diagnostics.luacheck,
|
|
||||||
null_ls.builtins.formatting.stylua,
|
|
||||||
-- Docker
|
|
||||||
null_ls.builtins.diagnostics.hadolint,
|
|
||||||
}
|
|
||||||
|
|
||||||
-- HACK: Handle old versions of null_ls for vim < 0.6 that don't support `setup`
|
|
||||||
if null_ls["setup"] ~= nil then
|
|
||||||
null_ls.setup({
|
|
||||||
on_attach = default_attach,
|
|
||||||
capabilities = merged_capabilities(),
|
|
||||||
sources = sources,
|
|
||||||
})
|
|
||||||
else
|
|
||||||
null_ls.config({
|
|
||||||
sources = sources,
|
|
||||||
})
|
|
||||||
require("lspconfig")["null-ls"].setup({
|
|
||||||
on_attach = default_attach,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function get_luadev_config()
|
local function get_luadev_config()
|
||||||
local luadev = utils.try_require("lua-dev")
|
local luadev = utils.try_require("lua-dev")
|
||||||
if luadev ~= nil then
|
if luadev ~= nil then
|
||||||
return luadev.setup({
|
return luadev.setup({
|
||||||
-- add any options here, or leave empty to use the default settings
|
-- add any options here, or leave empty to use the default settings
|
||||||
lspconfig = {
|
lspconfig = {
|
||||||
on_attach = default_attach,
|
on_attach = get_default_attach(),
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
completion = {
|
completion = {
|
||||||
@ -287,7 +230,7 @@ function M.config_lsp_intaller()
|
|||||||
utils.try_require("nvim-lsp-installer", function(lsp_installer)
|
utils.try_require("nvim-lsp-installer", function(lsp_installer)
|
||||||
-- Default options
|
-- Default options
|
||||||
local opts = {
|
local opts = {
|
||||||
on_attach = default_attach,
|
on_attach = get_default_attach(),
|
||||||
}
|
}
|
||||||
|
|
||||||
lsp_installer.on_server_ready(function(server)
|
lsp_installer.on_server_ready(function(server)
|
||||||
|
58
neovim/lua/plugins/null-ls/init.lua
Normal file
58
neovim/lua/plugins/null-ls/init.lua
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
local M = {}
|
||||||
|
local utils = require("utils")
|
||||||
|
|
||||||
|
function M.configure(options)
|
||||||
|
utils.try_require("null-ls", function(null_ls)
|
||||||
|
-- Load newer versions of plugins
|
||||||
|
local alex = require("plugins.null-ls.linters").alex
|
||||||
|
local ansiblelint = require("plugins.null-ls.linters").ansiblelint
|
||||||
|
|
||||||
|
-- Use ansiblelint for only ansible files
|
||||||
|
-- null_ls.builtins.diagnostics.ansiblelint.filetypes = { "yaml.ansible" }
|
||||||
|
|
||||||
|
local sources = {
|
||||||
|
-- Generic
|
||||||
|
null_ls.builtins.formatting.prettier,
|
||||||
|
null_ls.builtins.formatting.trim_whitespace,
|
||||||
|
null_ls.builtins.formatting.trim_newlines,
|
||||||
|
-- Fish
|
||||||
|
null_ls.builtins.formatting.fish_indent,
|
||||||
|
-- Python
|
||||||
|
null_ls.builtins.formatting.reorder_python_imports,
|
||||||
|
null_ls.builtins.formatting.black,
|
||||||
|
null_ls.builtins.diagnostics.mypy,
|
||||||
|
-- Go
|
||||||
|
null_ls.builtins.diagnostics.golangci_lint,
|
||||||
|
null_ls.builtins.formatting.gofmt,
|
||||||
|
-- Text
|
||||||
|
null_ls.builtins.code_actions.proselint,
|
||||||
|
null_ls.builtins.diagnostics.proselint,
|
||||||
|
null_ls.builtins.diagnostics.write_good,
|
||||||
|
-- null_ls.builtins.diagnostics.alex
|
||||||
|
alex,
|
||||||
|
-- Ansible
|
||||||
|
-- null_ls.builtins.diagnostics.ansiblelint,
|
||||||
|
ansiblelint,
|
||||||
|
-- Shell
|
||||||
|
null_ls.builtins.diagnostics.shellcheck,
|
||||||
|
-- Rust
|
||||||
|
null_ls.builtins.formatting.rustfmt,
|
||||||
|
-- Lua
|
||||||
|
null_ls.builtins.diagnostics.luacheck,
|
||||||
|
null_ls.builtins.formatting.stylua,
|
||||||
|
-- Docker
|
||||||
|
null_ls.builtins.diagnostics.hadolint,
|
||||||
|
}
|
||||||
|
|
||||||
|
if null_ls["setup"] ~= nil then
|
||||||
|
options.sources = sources
|
||||||
|
null_ls.setup(options)
|
||||||
|
else
|
||||||
|
-- HACK: Handle old versions of null_ls for vim < 0.6 that don't support `setup`
|
||||||
|
null_ls.config({ sources = sources })
|
||||||
|
require("lspconfig")["null-ls"].setup(options)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
71
neovim/lua/plugins/null-ls/linters.lua
Normal file
71
neovim/lua/plugins/null-ls/linters.lua
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
local null_ls = require("null-ls")
|
||||||
|
local helpers = require("null-ls.helpers")
|
||||||
|
|
||||||
|
M.alex = {
|
||||||
|
name = "alex",
|
||||||
|
method = null_ls.methods.DIAGNOSTICS,
|
||||||
|
filetypes = { "markdown" },
|
||||||
|
generator = null_ls.generator({
|
||||||
|
command = "alex",
|
||||||
|
args = { "--stdin", "--quiet" },
|
||||||
|
to_stdin = true,
|
||||||
|
from_stderr = true,
|
||||||
|
format = "line",
|
||||||
|
check_exit_code = function(code)
|
||||||
|
return code <= 1
|
||||||
|
end,
|
||||||
|
on_output = helpers.diagnostics.from_patterns({
|
||||||
|
{
|
||||||
|
pattern = [[ *(%d+):(%d+)-(%d+):(%d+) *(%w+) *(.+) +[%w]+ +([-%l]+)]],
|
||||||
|
groups = { "row", "col", "end_row", "end_col", "severity", "message", "code" },
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
|
||||||
|
M.ansiblelint = {
|
||||||
|
name = "ansiblelint",
|
||||||
|
method = null_ls.methods.DIAGNOSTICS,
|
||||||
|
filetypes = { "yaml.ansible" },
|
||||||
|
generator = null_ls.generator({
|
||||||
|
command = "ansible-lint",
|
||||||
|
to_stdin = true,
|
||||||
|
ignore_stderr = true,
|
||||||
|
args = { "-f", "codeclimate", "-q", "--nocolor", "$FILENAME" },
|
||||||
|
format = "json",
|
||||||
|
check_exit_code = function(code)
|
||||||
|
return code <= 2
|
||||||
|
end,
|
||||||
|
multiple_files = true,
|
||||||
|
on_output = function(params)
|
||||||
|
local severities = {
|
||||||
|
blocker = helpers.diagnostics.severities.error,
|
||||||
|
critical = helpers.diagnostics.severities.error,
|
||||||
|
major = helpers.diagnostics.severities.error,
|
||||||
|
minor = helpers.diagnostics.severities.warning,
|
||||||
|
info = helpers.diagnostics.severities.information,
|
||||||
|
}
|
||||||
|
params.messages = {}
|
||||||
|
for _, message in ipairs(params.output) do
|
||||||
|
local col = nil
|
||||||
|
local row = message.location.lines.begin
|
||||||
|
if type(row) == "table" then
|
||||||
|
row = row.line
|
||||||
|
col = row.column
|
||||||
|
end
|
||||||
|
table.insert(params.messages, {
|
||||||
|
row = row,
|
||||||
|
col = col,
|
||||||
|
message = message.check_name,
|
||||||
|
severity = severities[message.severity],
|
||||||
|
filename = message.location.path,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
return params.messages
|
||||||
|
end,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
@ -2,7 +2,6 @@ local utils = require("utils")
|
|||||||
local lsp_config = require("plugins.lsp")
|
local lsp_config = require("plugins.lsp")
|
||||||
|
|
||||||
-- Configure my various lsp stuffs
|
-- Configure my various lsp stuffs
|
||||||
lsp_config.config_null_ls()
|
|
||||||
lsp_config.config_lsp_intaller()
|
lsp_config.config_lsp_intaller()
|
||||||
lsp_config.config_lsp()
|
lsp_config.config_lsp()
|
||||||
lsp_config.config_lsp_ui()
|
lsp_config.config_lsp_ui()
|
||||||
|
Loading…
Reference in New Issue
Block a user