243 lines
9.0 KiB
Lua
243 lines
9.0 KiB
Lua
return {
|
|
-- lspconfig
|
|
{
|
|
"neovim/nvim-lspconfig",
|
|
enabled = true,
|
|
event = "BufReadPre",
|
|
dependencies = {
|
|
{
|
|
"folke/lazydev.nvim",
|
|
ft = "lua", -- only load on lua files
|
|
opts = {
|
|
library = {
|
|
-- See the configuration section for more details
|
|
-- Load luvit types when the `vim.uv` word is found
|
|
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
|
|
},
|
|
},
|
|
},
|
|
"mason.nvim",
|
|
{
|
|
"mason-org/mason-lspconfig.nvim",
|
|
version = "^1.0.0",
|
|
},
|
|
-- "hrsh7th/cmp-nvim-lsp",
|
|
},
|
|
opts = {
|
|
-- options for vim.diagnostic.config()
|
|
diagnostics = {
|
|
underline = true,
|
|
update_in_insert = true,
|
|
virtual_text = { spacing = 4, prefix = "●" },
|
|
severity_sort = true,
|
|
},
|
|
autoformat = true,
|
|
servers = {
|
|
lua_ls = {
|
|
mason = true,
|
|
settings = {
|
|
Lua = {
|
|
workspace = {
|
|
checkThirdParty = false,
|
|
},
|
|
completion = {
|
|
callSnippet = "Replace",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
ltex = {
|
|
mason = true,
|
|
settings = {
|
|
ltex = {
|
|
language = "en-AU",
|
|
},
|
|
},
|
|
},
|
|
omnisharp = {},
|
|
powershell_es = {
|
|
bundle_path = 'c:/Users/Solomon/scripts/PowerShellEditorServices',
|
|
shell = 'powershell.exe',
|
|
},
|
|
-- angularls = {
|
|
-- -- cmd = { "ngserver", "--stdio", "--tsProbeLocations", require("lazyvim.utils").get_root(), "--ngProbeLocations", require("lazyvim.utils").get_root(), },
|
|
-- -- on_new_config = function(new_config, new_root_dir)
|
|
-- -- new_config.cmd = cmd
|
|
-- -- end,
|
|
-- },
|
|
},
|
|
setup = {
|
|
-- additional setup can be added here.
|
|
omnisharp = function(_, _)
|
|
require("lazyvim.utils").on_attach(function(client, _)
|
|
if client.name == "omnisharp" then
|
|
---@type string[]
|
|
local tokenModifiers =
|
|
client.server_capabilities.semanticTokensProvider.legend.tokenModifiers
|
|
for i, v in ipairs(tokenModifiers) do
|
|
tokenModifiers[i] = v:gsub(" ", "_")
|
|
end
|
|
---@type string[]
|
|
local tokenTypes = client.server_capabilities.semanticTokensProvider.legend.tokenTypes
|
|
for i, v in ipairs(tokenTypes) do
|
|
tokenTypes[i] = v:gsub(" ", "_")
|
|
end
|
|
end
|
|
end)
|
|
return false
|
|
end,
|
|
},
|
|
},
|
|
config = function(_, opts)
|
|
local Util = require("lazyvim.utils")
|
|
-- setup autoformat
|
|
require("lazyvim.plugins.lsp.format").autoformat = opts.autoformat
|
|
|
|
-- setup formatting and keymaps
|
|
Util.on_attach(function(client, buffer)
|
|
require("lazyvim.plugins.lsp.format").on_attach(client, buffer)
|
|
require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer)
|
|
end)
|
|
|
|
-- diagnostics
|
|
for name, icon in pairs(require("lazyvim.config.icons").diagnostics) do
|
|
name = "DiagnosticSign" .. name
|
|
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
|
|
end
|
|
|
|
if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then
|
|
opts.diagnostics.virtual_text.prefix = vim.fn.has("nvim-0.10.0") == 0 and "●"
|
|
or function(diagnostic)
|
|
local icons = require("lazyvim.config").icons.diagnostics
|
|
for d, icon in pairs(icons) do
|
|
if diagnostic.severity == vim.diagnostic.severity[d:upper()] then
|
|
return icon
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
vim.diagnostic.config(vim.deepcopy(opts.diagnostics))
|
|
|
|
local servers = opts.servers
|
|
local capabilities = vim.tbl_deep_extend(
|
|
"force",
|
|
{},
|
|
vim.lsp.protocol.make_client_capabilities(),
|
|
-- require("cmp_nvim_lsp").default_capabilities(),
|
|
require("blink.cmp").get_lsp_capabilities(),
|
|
opts.capabilities or {}
|
|
)
|
|
|
|
local function setup(server)
|
|
local server_opts = vim.tbl_deep_extend("force", {
|
|
capabilities = vim.deepcopy(capabilities),
|
|
}, servers[server] or {})
|
|
|
|
if opts.setup[server] then
|
|
if opts.setup[server](server, server_opts) then
|
|
return
|
|
end
|
|
elseif opts.setup["*"] then
|
|
if opts.setup["*"](server, server_opts) then
|
|
return
|
|
end
|
|
end
|
|
vim.lsp.enable(server)
|
|
vim.lsp.config(server, server_opts)
|
|
end
|
|
|
|
-- get all the servers that are available thourgh mason-lspconfig
|
|
local have_mason, mlsp = pcall(require, "mason-lspconfig")
|
|
local all_mslp_servers = {}
|
|
if have_mason then
|
|
all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package)
|
|
end
|
|
|
|
local ensure_installed = {} ---@type string[]
|
|
for server, server_opts in pairs(servers) do
|
|
if server_opts then
|
|
server_opts = server_opts == true and {} or server_opts
|
|
-- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig
|
|
if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then
|
|
setup(server)
|
|
else
|
|
ensure_installed[#ensure_installed + 1] = server
|
|
end
|
|
end
|
|
end
|
|
|
|
if have_mason then
|
|
mlsp.setup({ ensure_installed = ensure_installed })
|
|
mlsp.setup_handlers({ setup })
|
|
end
|
|
end,
|
|
},
|
|
|
|
-- formatting
|
|
{
|
|
"stevearc/conform.nvim",
|
|
enabled = true,
|
|
opts = {
|
|
formatters_by_ft = {
|
|
lua = { "stylua" },
|
|
-- Conform will run multiple formatters sequentially
|
|
python = { "isort", "black" },
|
|
-- Use a sub-list to run only the first available formatter
|
|
typescript = { { "prettierd", "prettier" } },
|
|
cs = { "csharpier" },
|
|
},
|
|
formatters = {
|
|
csharpier = {
|
|
command = "dotnet-csharpier",
|
|
args = { "--write-stdout" },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
-- cmdline tools and lsp servers
|
|
{
|
|
"williamboman/mason.nvim",
|
|
version = "^1.0.0",
|
|
enabled = true,
|
|
cmd = "Mason",
|
|
keys = { { "<leader>lM", "<cmd>Mason<cr>", desc = "Mason" } },
|
|
opts = {
|
|
automatic_istallation = false,
|
|
ensure_installed = {
|
|
"stylua",
|
|
"shellcheck",
|
|
"shfmt",
|
|
},
|
|
},
|
|
config = function(_, opts)
|
|
require("mason").setup()
|
|
local mr = require("mason-registry")
|
|
for _, tool in ipairs(opts.ensure_installed) do
|
|
local p = mr.get_package(tool)
|
|
if not p:is_installed() then
|
|
p:install()
|
|
end
|
|
end
|
|
end,
|
|
},
|
|
|
|
-- language specific tooling
|
|
{
|
|
"simrat39/rust-tools.nvim",
|
|
enabled = false,
|
|
opts = {
|
|
server = {
|
|
on_attach = function(_, bufnr)
|
|
local rt = require("rust-tools")
|
|
-- Hover actions
|
|
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
|
|
-- Code action groups
|
|
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
|
|
end,
|
|
},
|
|
},
|
|
},
|
|
}
|