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" },
|
"markdown-preview.nvim": { "branch": "master", "commit": "9becceee5740b7db6914da87358a183ad11b2049" },
|
||||||
"markmap.nvim": { "branch": "main", "commit": "3befc2a54c2448a16c30c1c7762aab263f22946a" },
|
"markmap.nvim": { "branch": "main", "commit": "3befc2a54c2448a16c30c1c7762aab263f22946a" },
|
||||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "4eb8e15e3c0757303d4c6dea64d2981fc679e990" },
|
"mason-lspconfig.nvim": { "branch": "main", "commit": "4eb8e15e3c0757303d4c6dea64d2981fc679e990" },
|
||||||
|
"mason-tool-installer.nvim": { "branch": "main", "commit": "8b70e7f1e0a4119c1234c3bde4a01c241cabcc74" },
|
||||||
"mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" },
|
"mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" },
|
||||||
"mdeval.nvim": { "branch": "master", "commit": "2654caf8ecaad702b50199d18e39cff23d81e0ba" },
|
"mdeval.nvim": { "branch": "master", "commit": "2654caf8ecaad702b50199d18e39cff23d81e0ba" },
|
||||||
"mini.nvim": { "branch": "main", "commit": "b5645ac6eefce8e7af9d7dd4e5e296a81cba8a10" },
|
"mini.nvim": { "branch": "main", "commit": "b5645ac6eefce8e7af9d7dd4e5e296a81cba8a10" },
|
||||||
|
|
|
@ -17,6 +17,7 @@ local servers = {
|
||||||
docker_compose_language_service = {},
|
docker_compose_language_service = {},
|
||||||
dockerls = {},
|
dockerls = {},
|
||||||
emmet_ls = {},
|
emmet_ls = {},
|
||||||
|
eslint = {},
|
||||||
gopls = {},
|
gopls = {},
|
||||||
julials = {},
|
julials = {},
|
||||||
lua_ls = {
|
lua_ls = {
|
||||||
|
@ -42,6 +43,16 @@ local servers = {
|
||||||
yamlls = {},
|
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 function on_attach(client, bufnr)
|
||||||
local map = vim.keymap.set
|
local map = vim.keymap.set
|
||||||
map("n", "[d", "<cmd>lua vim.diagnostic.goto_prev()<cr>", { buffer = bufnr, desc = "Previous diagnostic" })
|
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
|
-- 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/
|
-- 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("InsertEnter", {
|
||||||
vim.api.nvim_create_autocmd("InsertLeave", { callback = function() vim.diagnostic.config({ virtual_text = true, }) end })
|
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({
|
lsp.setup({
|
||||||
default_mappings = false,
|
default_mappings = false,
|
||||||
|
@ -136,14 +155,14 @@ lspconfig.nushell.setup({})
|
||||||
local python_path
|
local python_path
|
||||||
-- ensure python virtualenv is determined automatically on lsp start
|
-- ensure python virtualenv is determined automatically on lsp start
|
||||||
lspconfig.pyright.setup({
|
lspconfig.pyright.setup({
|
||||||
on_attach = function(client, bufnr)
|
on_attach = function(client, bufnr)
|
||||||
if python_path == nil then
|
if python_path == nil then
|
||||||
python_path, _ = require("util").get_python_venv(client.config.root_dir)
|
python_path, _ = require("util").get_python_venv(client.config.root_dir)
|
||||||
end
|
end
|
||||||
-- print(string.format("[PYTHON VENV]: %s", vim.inspect(python_path)))
|
-- print(string.format("[PYTHON VENV]: %s", vim.inspect(python_path)))
|
||||||
client.config.settings.python.pythonPath = python_path
|
client.config.settings.python.pythonPath = python_path
|
||||||
on_attach(client, bufnr)
|
on_attach(client, bufnr)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
lspconfig.ruff_lsp.setup({
|
lspconfig.ruff_lsp.setup({
|
||||||
on_attach = function(client, bufnr)
|
on_attach = function(client, bufnr)
|
||||||
|
@ -161,4 +180,3 @@ if require("util").is_available("arduino") then
|
||||||
on_new_config = require("arduino").on_new_config,
|
on_new_config = require("arduino").on_new_config,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,9 @@ return {
|
||||||
"williamboman/mason-lspconfig.nvim",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
cmd = { "LspInstall", "LspUninstall" },
|
cmd = { "LspInstall", "LspUninstall" },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
event = "BufReadPost",
|
event = "BufReadPost",
|
||||||
config = function()
|
config = function()
|
||||||
|
@ -91,7 +94,7 @@ return {
|
||||||
end
|
end
|
||||||
end
|
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("vale", { linters.markdown, linters.text, linters.quarto })
|
||||||
per_cmd("shellcheck", { linters.sh, linters.bash })
|
per_cmd("shellcheck", { linters.sh, linters.bash })
|
||||||
per_cmd("eslint_d", {
|
per_cmd("eslint_d", {
|
||||||
|
|
Loading…
Reference in a new issue