Migrate away from null-ls
parent
adef7b6f56
commit
527da4d59f
|
@ -22,7 +22,7 @@ presets = "cpu:1:default,proc:0:default cpu:0:default,mem:0:default,net:0:defaul
|
|||
|
||||
#* Set to True to enable "h,j,k,l,g,G" keys for directional control in lists.
|
||||
#* Conflicting keys for h:"help" and k:"kill" is accessible while holding shift.
|
||||
vim_keys = true
|
||||
vim_keys = True
|
||||
|
||||
#* Rounded corners on boxes, is ignored if TTY mode is ON.
|
||||
rounded_corners = True
|
||||
|
|
|
@ -123,7 +123,8 @@ return require("lazy").setup({
|
|||
"hrsh7th/cmp-nvim-lua", -- Nvim-Lua source for nvim-cmp
|
||||
"hrsh7th/cmp-omni", -- omnifunc source for nvim-cmp
|
||||
"hrsh7th/nvim-cmp", -- completion integration
|
||||
"jose-elias-alvarez/null-ls.nvim", -- Linting and formatting
|
||||
"mhartington/formatter.nvim", -- formatting support
|
||||
"mfussenegger/nvim-lint", -- linting support
|
||||
|
||||
-- LSP language specific
|
||||
"folke/neodev.nvim", -- Built-in Lua integration with LSP
|
||||
|
|
|
@ -2,76 +2,81 @@
|
|||
-- - LSP diagnostics config -
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 = {
|
||||
-- Python
|
||||
null_ls.builtins.diagnostics.flake8,
|
||||
null_ls.builtins.formatting.isort,
|
||||
null_ls.builtins.formatting.autopep8,
|
||||
|
||||
-- Kotlin
|
||||
null_ls.builtins.formatting.ktlint,
|
||||
null_ls.builtins.diagnostics.ktlint,
|
||||
|
||||
-- Clojure
|
||||
null_ls.builtins.diagnostics.clj_kondo,
|
||||
null_ls.builtins.formatting.joker.with({
|
||||
filetypes = { "clojure" },
|
||||
}),
|
||||
|
||||
-- C++ and C
|
||||
null_ls.builtins.formatting.clang_format.with({
|
||||
filetypes = { "cpp", "c" },
|
||||
}),
|
||||
null_ls.builtins.diagnostics.clang_check,
|
||||
|
||||
-- Cmake
|
||||
null_ls.builtins.formatting.cmake_format,
|
||||
|
||||
-- Lua
|
||||
null_ls.builtins.formatting.stylua,
|
||||
null_ls.builtins.diagnostics.luacheck.with({
|
||||
extra_args = { "--config", vim.fn.stdpath("config") .. "/.luacheckrc" },
|
||||
}),
|
||||
|
||||
-- Dart
|
||||
null_ls.builtins.formatting.dart_format,
|
||||
|
||||
-- Go
|
||||
null_ls.builtins.formatting.gofmt,
|
||||
|
||||
-- Rust
|
||||
null_ls.builtins.formatting.rustfmt,
|
||||
|
||||
-- Zig
|
||||
null_ls.builtins.formatting.zigfmt,
|
||||
|
||||
-- Java
|
||||
null_ls.builtins.formatting.google_java_format,
|
||||
|
||||
-- General
|
||||
null_ls.builtins.formatting.trim_newlines,
|
||||
null_ls.builtins.formatting.trim_whitespace,
|
||||
null_ls.builtins.hover.dictionary.with({
|
||||
filetypes = { "text", "markdown", "vimwiki" },
|
||||
}),
|
||||
null_ls.builtins.diagnostics.misspell,
|
||||
null_ls.builtins.code_actions.gitsigns,
|
||||
|
||||
-- Godot
|
||||
custom_sources.formatters.gdformat,
|
||||
custom_sources.diagnostics.gdlint,
|
||||
|
||||
-- Vim-Ledger
|
||||
custom_sources.completion.ledger,
|
||||
require("formatter").setup({
|
||||
filetype = {
|
||||
python = {
|
||||
require("formatter.filetypes.python").isort,
|
||||
require("formatter.filetypes.python").autopep8,
|
||||
},
|
||||
kotlin = {
|
||||
require("formatter.filetypes.kotlin").ktlint,
|
||||
},
|
||||
cpp = {
|
||||
require("formatter.filetypes.cpp").clangformat,
|
||||
},
|
||||
c = {
|
||||
require("formatter.filetypes.c").clangformat,
|
||||
},
|
||||
cmake = {
|
||||
require("formatter.filetypes.cmake").cmakeformat,
|
||||
},
|
||||
lua = {
|
||||
require("formatter.filetypes.lua").stylua,
|
||||
},
|
||||
dart = {
|
||||
require("formatter.filetypes.dart").dartformat,
|
||||
},
|
||||
go = {
|
||||
require("formatter.filetypes.go").gofmt,
|
||||
},
|
||||
rust = {
|
||||
require("formatter.filetypes.rust").rustfmt,
|
||||
},
|
||||
zig = {
|
||||
require("formatter.filetypes.zig").zigfmt,
|
||||
},
|
||||
java = {
|
||||
require("formatter.filetypes.java").clangformat,
|
||||
},
|
||||
godot = {
|
||||
require("esensar.lsp.formatters.gdformat"),
|
||||
},
|
||||
["*"] = {
|
||||
require("formatter.filetypes.any").remove_trailing_whitespace,
|
||||
},
|
||||
},
|
||||
on_attach = common_config.on_attach,
|
||||
})
|
||||
|
||||
require("lint").linters_by_ft = {
|
||||
python = { "flake8" },
|
||||
kotlin = { "ktlint" },
|
||||
clojure = { "clj_kondo" },
|
||||
c = { "clang_check" },
|
||||
cpp = { "clang_check" },
|
||||
lua = { "luacheck" },
|
||||
gdscript = { "gdlint" },
|
||||
}
|
||||
|
||||
require("lint").linters.misspell = {
|
||||
name = "Misspell",
|
||||
stdin = true,
|
||||
cmd = "misspell",
|
||||
parser = require("lint.parser").from_pattern("(%w+):(%d+):(%d+):(.+)", { "file", "lnum", "col", "message" }),
|
||||
}
|
||||
|
||||
require("lint").linters.gdlint = {
|
||||
name = "GDLint",
|
||||
cmd = "gdlint",
|
||||
stdin = true,
|
||||
args = {
|
||||
function()
|
||||
vim.fn.expand("%")
|
||||
end,
|
||||
},
|
||||
stream = "stderr",
|
||||
parser = require("lint.parser").from_pattern("(.+):(%d+): Error: (.*)", { "file", "lnum", "message" }),
|
||||
}
|
||||
|
||||
vim.keymap.set("n", "]w", vim.diagnostic.goto_next)
|
||||
vim.keymap.set("n", "[w", vim.diagnostic.goto_prev)
|
||||
vim.api.nvim_create_user_command(
|
||||
|
@ -85,3 +90,13 @@ vim.api.nvim_create_user_command(
|
|||
{ desc = "Show LSP buffer warnings in a location list" }
|
||||
)
|
||||
vim.api.nvim_create_user_command("Format", vim.lsp.buf.format, { desc = "Format current buffer using LSP" })
|
||||
|
||||
-- Auto linting
|
||||
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||
callback = function()
|
||||
vim.cmd("FormatWrite")
|
||||
require("lint").try_lint()
|
||||
require("lint").try_lint({ "codespell" })
|
||||
require("lint").try_lint({ "misspell" })
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
return {
|
||||
exe = "gdformat",
|
||||
args = {
|
||||
"--diff",
|
||||
"-"
|
||||
},
|
||||
stdin = true
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
local null_ls = require("null-ls")
|
||||
local helpers = require("null-ls.helpers")
|
||||
|
||||
return {
|
||||
name = "gdformat",
|
||||
meta = {
|
||||
url = "https://github.com/Scony/godot-gdscript-toolkit",
|
||||
description = "Formatter for GDScript",
|
||||
},
|
||||
method = null_ls.methods.FORMATTING,
|
||||
filetypes = { "gdscript" },
|
||||
generator = helpers.formatter_factory({
|
||||
command = "gdformat",
|
||||
args = { "--diff", "-" },
|
||||
to_stdin = true,
|
||||
}),
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
local null_ls = require("null-ls")
|
||||
local helpers = require("null-ls.helpers")
|
||||
|
||||
return {
|
||||
name = "gdlint",
|
||||
meta = {
|
||||
url = "https://github.com/Scony/godot-gdscript-toolkit",
|
||||
description = "Linter for GDScript",
|
||||
},
|
||||
method = null_ls.methods.DIAGNOSTICS_ON_SAVE,
|
||||
filetypes = { "gdscript" },
|
||||
generator = helpers.generator_factory({
|
||||
command = "gdlint",
|
||||
args = { "$FILENAME" },
|
||||
format = "line",
|
||||
from_stderr = true,
|
||||
multiple_files = true,
|
||||
check_exit_code = function(code)
|
||||
return code == 0
|
||||
end,
|
||||
on_output = helpers.diagnostics.from_patterns({
|
||||
{
|
||||
pattern = "(.+):(%d+): Error: (.*)",
|
||||
groups = { "filename", "row", "message" },
|
||||
overrides = {
|
||||
diagnostic = {
|
||||
severity = helpers.diagnostics.severities.error,
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
}),
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
-- Place for custom null-ls sources
|
||||
return {
|
||||
formatters = {
|
||||
gdformat = require("esensar.lsp.null-ls_sources.gdformat"),
|
||||
},
|
||||
diagnostics = {
|
||||
gdlint = require("esensar.lsp.null-ls_sources.gdlint"),
|
||||
},
|
||||
completion = {
|
||||
ledger = require("esensar.lsp.null-ls_sources.ledger"),
|
||||
},
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
local null_ls = require("null-ls")
|
||||
local helpers = require("null-ls.helpers")
|
||||
|
||||
return {
|
||||
name = "ledger-complete",
|
||||
meta = {
|
||||
url = "https://github.com/ledger/vim-ledger",
|
||||
description = "vim-ledger omnifunc completion source",
|
||||
},
|
||||
method = null_ls.methods.COMPLETION,
|
||||
filetypes = { "ledger" },
|
||||
generator = helpers.generator_factory({
|
||||
fn = function(params, done)
|
||||
-- This can be slow
|
||||
if #params.word_to_complete < 4 then
|
||||
done({ { items = {}, isIncomplete = false } })
|
||||
return
|
||||
end
|
||||
|
||||
vim.fn.LedgerComplete(1, nil)
|
||||
local results = vim.fn.LedgerComplete(0, #params.word_to_complete)
|
||||
|
||||
local words = {}
|
||||
local items = {}
|
||||
for result in ipairs(results) do
|
||||
table.insert(words, result)
|
||||
end
|
||||
|
||||
for _, word in ipairs(words) do
|
||||
table.insert(items, {
|
||||
label = word,
|
||||
insertText = word,
|
||||
})
|
||||
end
|
||||
|
||||
done({ { items = items, isIncomplete = #items == 0 } })
|
||||
end,
|
||||
async = true,
|
||||
}),
|
||||
}
|
|
@ -2,12 +2,18 @@
|
|||
-- - LSP servers configuration -
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
require("neodev").setup({
|
||||
library = { plugins = { "neotest", "plenary.nvim" }, types = true },
|
||||
-- Always add neovim plugins into lua_ls library, even if not neovim config
|
||||
override = function(root_dir, library)
|
||||
library.enabled = true
|
||||
library.plugins = true
|
||||
end,
|
||||
})
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup()
|
||||
require("neodev").setup({
|
||||
library = { plugins = { "neotest", "plenary.nvim" }, types = true },
|
||||
})
|
||||
local common_config = require("esensar.lsp.server_config")
|
||||
|
||||
-- Language specific LSP config overrides
|
||||
|
|
Loading…
Reference in New Issue