nvim: Add automatic mason tool installation
Using mason-tool-installer we ensure everything is installed correctly. Need to improve the collection of things to install. Currently we just do everything in lsp configuration file, even the non-lsp things (formatters/linters) which should be sourced where they belong not in that file.
This commit is contained in:
parent
ab06ef922b
commit
eec90ad7e2
3 changed files with 34 additions and 12 deletions
|
@ -40,6 +40,7 @@
|
|||
"markdown-preview.nvim": { "branch": "master", "commit": "9becceee5740b7db6914da87358a183ad11b2049" },
|
||||
"markmap.nvim": { "branch": "main", "commit": "3befc2a54c2448a16c30c1c7762aab263f22946a" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "4eb8e15e3c0757303d4c6dea64d2981fc679e990" },
|
||||
"mason-tool-installer.nvim": { "branch": "main", "commit": "8b70e7f1e0a4119c1234c3bde4a01c241cabcc74" },
|
||||
"mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" },
|
||||
"mdeval.nvim": { "branch": "master", "commit": "2654caf8ecaad702b50199d18e39cff23d81e0ba" },
|
||||
"mini.nvim": { "branch": "main", "commit": "b5645ac6eefce8e7af9d7dd4e5e296a81cba8a10" },
|
||||
|
|
|
@ -17,6 +17,7 @@ local servers = {
|
|||
docker_compose_language_service = {},
|
||||
dockerls = {},
|
||||
emmet_ls = {},
|
||||
eslint = {},
|
||||
gopls = {},
|
||||
julials = {},
|
||||
lua_ls = {
|
||||
|
@ -42,6 +43,16 @@ local servers = {
|
|||
yamlls = {},
|
||||
}
|
||||
|
||||
-- TODO installed for conform/nvim-lint so should be sourced from there not here
|
||||
local to_mason =
|
||||
{ "stylua", "shellcheck", "shfmt", "markdownlint", "bibtex-tidy", "jq", "prettier", "ruff", unpack(servers) }
|
||||
require("mason-tool-installer").setup({
|
||||
-- a list of all tools you want to ensure are installed upon
|
||||
-- start
|
||||
ensure_installed = to_mason,
|
||||
start_delay = 3000,
|
||||
})
|
||||
|
||||
local function on_attach(client, bufnr)
|
||||
local map = vim.keymap.set
|
||||
map("n", "[d", "<cmd>lua vim.diagnostic.goto_prev()<cr>", { buffer = bufnr, desc = "Previous diagnostic" })
|
||||
|
@ -118,8 +129,16 @@ end
|
|||
|
||||
-- Display diagnostics as virtual text only if not in insert mode
|
||||
-- https://lr.artemislena.eu/r/neovim/comments/12inp4c/disable_diagnostics_virtual_text_when_in_insert/jqqifwk/
|
||||
vim.api.nvim_create_autocmd("InsertEnter", { callback = function() vim.diagnostic.config({ virtual_text = false, }) end })
|
||||
vim.api.nvim_create_autocmd("InsertLeave", { callback = function() vim.diagnostic.config({ virtual_text = true, }) end })
|
||||
vim.api.nvim_create_autocmd("InsertEnter", {
|
||||
callback = function()
|
||||
vim.diagnostic.config({ virtual_text = false })
|
||||
end,
|
||||
})
|
||||
vim.api.nvim_create_autocmd("InsertLeave", {
|
||||
callback = function()
|
||||
vim.diagnostic.config({ virtual_text = true })
|
||||
end,
|
||||
})
|
||||
|
||||
lsp.setup({
|
||||
default_mappings = false,
|
||||
|
@ -161,4 +180,3 @@ if require("util").is_available("arduino") then
|
|||
on_new_config = require("arduino").on_new_config,
|
||||
})
|
||||
end
|
||||
|
||||
|
|
|
@ -55,6 +55,9 @@ return {
|
|||
"williamboman/mason-lspconfig.nvim",
|
||||
cmd = { "LspInstall", "LspUninstall" },
|
||||
},
|
||||
{
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
},
|
||||
},
|
||||
event = "BufReadPost",
|
||||
config = function()
|
||||
|
@ -91,7 +94,7 @@ return {
|
|||
end
|
||||
end
|
||||
end
|
||||
per_cmd("markdownlint", { linters.markdown })
|
||||
per_cmd("markdownlint", { linters.markdown, linters.quarto })
|
||||
per_cmd("vale", { linters.markdown, linters.text, linters.quarto })
|
||||
per_cmd("shellcheck", { linters.sh, linters.bash })
|
||||
per_cmd("eslint_d", {
|
||||
|
|
Loading…
Reference in a new issue