add mason util and lsp changes for current state
This commit is contained in:
parent
db15bab692
commit
3f99900ede
|
@ -1,4 +1,6 @@
|
||||||
return { -- LSP Configuration & Plugins
|
return {
|
||||||
|
{
|
||||||
|
-- LSP Configuration & Plugins
|
||||||
'neovim/nvim-lspconfig',
|
'neovim/nvim-lspconfig',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
-- Automatically install LSPs and related tools to stdpath for Neovim
|
-- Automatically install LSPs and related tools to stdpath for Neovim
|
||||||
|
@ -157,21 +159,31 @@ return { -- LSP Configuration & Plugins
|
||||||
local servers = {
|
local servers = {
|
||||||
-- clangd = {},
|
-- clangd = {},
|
||||||
-- gopls = {},
|
-- gopls = {},
|
||||||
pyright = {},
|
pyright = {
|
||||||
pylsp = {
|
settings = {
|
||||||
on_attach = on_attach,
|
python = {
|
||||||
capabilities = capabilities,
|
analysis = {
|
||||||
settings = {
|
autoSearchPaths = true,
|
||||||
pylsp = {
|
diagnosticMode = 'workspace',
|
||||||
plugins = {
|
useLibraryCodeForTypes = true,
|
||||||
pycodestyle = {
|
autoImportCompletions = true,
|
||||||
ignore = {},
|
},
|
||||||
maxLineLength = 120,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
disableLanguageServices = false,
|
||||||
},
|
},
|
||||||
|
-- pylsp = {
|
||||||
|
-- settings = {
|
||||||
|
-- pylsp = {
|
||||||
|
-- plugins = {
|
||||||
|
-- pycodestyle = {
|
||||||
|
-- ignore = {},
|
||||||
|
-- maxLineLength = 120,
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- }
|
||||||
|
-- }
|
||||||
|
-- },
|
||||||
-- rust_analyzer = {},
|
-- rust_analyzer = {},
|
||||||
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
|
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
|
||||||
--
|
--
|
||||||
|
@ -212,7 +224,18 @@ return { -- LSP Configuration & Plugins
|
||||||
vim.list_extend(ensure_installed, {
|
vim.list_extend(ensure_installed, {
|
||||||
'stylua', -- Used to format Lua code
|
'stylua', -- Used to format Lua code
|
||||||
})
|
})
|
||||||
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
|
-- require('mason-tool-installer').setup { ensure_installed = ensure_installed }
|
||||||
|
-- INFO: Using my own utils function instead of mason-lspconfig as it checks if the stuff is already installed
|
||||||
|
-- outside of mason. This is useful for NixOS setup where mason version just doesn't work sometimes due to libc issues.
|
||||||
|
require('utils.mason').install {
|
||||||
|
-- "python-lsp-server",
|
||||||
|
'pyright',
|
||||||
|
'bash-language-server',
|
||||||
|
-- "rnix-lsp",
|
||||||
|
'lua-language-server',
|
||||||
|
-- "docker-compose-language-service",
|
||||||
|
-- "nil",
|
||||||
|
}
|
||||||
|
|
||||||
require('mason-lspconfig').setup {
|
require('mason-lspconfig').setup {
|
||||||
handlers = {
|
handlers = {
|
||||||
|
@ -227,4 +250,24 @@ return { -- LSP Configuration & Plugins
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
}
|
},
|
||||||
|
-- Show LSP explorer of functions and classes etc.
|
||||||
|
{
|
||||||
|
'hedyhli/outline.nvim',
|
||||||
|
lazy = true,
|
||||||
|
cmd = { 'Outline', 'OutlineOpen' },
|
||||||
|
keys = { -- Example mapping to toggle outline
|
||||||
|
{ '<leader>o', '<cmd>Outline<CR>', desc = 'Toggle outline' },
|
||||||
|
},
|
||||||
|
opts = {},
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Shows where you are in the file LSP wise (which class/function etc)
|
||||||
|
{
|
||||||
|
'ray-x/lsp_signature.nvim',
|
||||||
|
event = 'VeryLazy',
|
||||||
|
config = function(_, opts)
|
||||||
|
require('lsp_signature').setup(opts)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
-- any cases where name of package is different from the binary name
|
||||||
|
local name_to_bin = {
|
||||||
|
["csharp-language-server"] = "csharp-ls",
|
||||||
|
["python-lsp-server"] = "pylsp",
|
||||||
|
["docker-compose-language-service"] = "docker-compose-langserver",
|
||||||
|
}
|
||||||
|
|
||||||
|
M.install = function(ensure_installed)
|
||||||
|
-- Allow for passing in a single string
|
||||||
|
if type(ensure_installed) == "string" then
|
||||||
|
ensure_installed = { ensure_installed }
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Function to check if the executable exists in the PATH
|
||||||
|
local function executable_exists(name)
|
||||||
|
if name_to_bin[name] then
|
||||||
|
return vim.fn.executable(name) == 1 or vim.fn.executable(name_to_bin[name]) == 1
|
||||||
|
end
|
||||||
|
return vim.fn.executable(name) == 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local registry = require("mason-registry")
|
||||||
|
registry.refresh(function()
|
||||||
|
for _, pkg_name in ipairs(ensure_installed) do
|
||||||
|
local pkg = registry.get_package(pkg_name)
|
||||||
|
if not executable_exists(pkg_name) and not pkg:is_installed() then
|
||||||
|
pkg:install()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
Loading…
Reference in New Issue