astro-nvim-v3 - Update: add context function for neo
This commit is contained in:
@@ -4,219 +4,220 @@
|
||||
|
||||
---@type LazySpec
|
||||
return {
|
||||
"AstroNvim/astrolsp",
|
||||
---@type AstroLSPOpts
|
||||
opts = {
|
||||
-- Configuration table of features provided by AstroLSP
|
||||
features = {
|
||||
autoformat = false, -- enable or disable auto formatting on start
|
||||
codelens = false, -- enable/disable codelens refresh on start
|
||||
inlay_hints = false, -- enable/disable inlay hints on start
|
||||
semantic_tokens = true, -- enable/disable semantic token highlighting
|
||||
},
|
||||
-- customize lsp formatting options
|
||||
formatting = require("plugins.configs.lsp.formatting"),
|
||||
-- enable servers that you already have installed without mason
|
||||
servers = {},
|
||||
-- customize language server configuration options passed to `lspconfig`
|
||||
---@diagnostic disable: missing-fields
|
||||
config = {
|
||||
-- clangd = require "plugins.configs.lsp.config.clangd",
|
||||
basedpyright = require("plugins.configs.lsp.config.basedpyright"),
|
||||
"AstroNvim/astrolsp",
|
||||
---@type AstroLSPOpts
|
||||
opts = {
|
||||
-- Configuration table of features provided by AstroLSP
|
||||
features = {
|
||||
autoformat = false, -- enable or disable auto formatting on start
|
||||
codelens = false, -- enable/disable codelens refresh on start
|
||||
inlay_hints = false, -- enable/disable inlay hints on start
|
||||
semantic_tokens = true, -- enable/disable semantic token highlighting
|
||||
},
|
||||
-- customize lsp formatting options
|
||||
formatting = require("plugins.configs.lsp.formatting"),
|
||||
-- enable servers that you already have installed without mason
|
||||
servers = {},
|
||||
-- customize language server configuration options passed to `lspconfig`
|
||||
---@diagnostic disable: missing-fields
|
||||
config = {
|
||||
-- clangd = require "plugins.configs.lsp.config.clangd",
|
||||
basedpyright = require("plugins.configs.lsp.config.basedpyright"),
|
||||
|
||||
jedi_language_server = {
|
||||
init_options = {
|
||||
completion = {
|
||||
disableSnippets = true,
|
||||
},
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
},
|
||||
jediSettings = {
|
||||
autoImportModules = {
|
||||
"numpy",
|
||||
"pandas",
|
||||
"torch",
|
||||
"sklearn",
|
||||
},
|
||||
},
|
||||
workspace = {
|
||||
environmentPath = "/home/duckq1u/miniconda3/envs/OCR3/bin/python"
|
||||
}
|
||||
},
|
||||
},
|
||||
jedi_language_server = {
|
||||
init_options = {
|
||||
completion = {
|
||||
disableSnippets = true,
|
||||
},
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
},
|
||||
jediSettings = {
|
||||
autoImportModules = {
|
||||
"numpy",
|
||||
"pandas",
|
||||
"torch",
|
||||
"sklearn",
|
||||
},
|
||||
},
|
||||
workspace = {
|
||||
environmentPath = "/home/duckq1u/miniconda3/envs/OCR3/bin/python",
|
||||
ignore = { "/home/duckq1u/miniconda3/envs/OCR3/lib/python3.11/site-packages/transformers/mode ls/albert/configuration_albert.py" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
ruff = {
|
||||
init_options = {
|
||||
settings = {
|
||||
lint = {
|
||||
unfixable = { "F401" },
|
||||
select = {
|
||||
"ALL",
|
||||
},
|
||||
ignore = {
|
||||
"ANN",
|
||||
"COM",
|
||||
"C90",
|
||||
"DJ",
|
||||
"EXE",
|
||||
"T10",
|
||||
"TID",
|
||||
"D100",
|
||||
"D101",
|
||||
"D102",
|
||||
"D103",
|
||||
"D104",
|
||||
"D105",
|
||||
"D106",
|
||||
"D107",
|
||||
"D200",
|
||||
"D205",
|
||||
"D212",
|
||||
"D400",
|
||||
"D401",
|
||||
"D415",
|
||||
"E402",
|
||||
"E501",
|
||||
"ERA001",
|
||||
"TRY003",
|
||||
"TD002",
|
||||
"TD003",
|
||||
"T201",
|
||||
"FIX002",
|
||||
"N803",
|
||||
"PD901",
|
||||
-- "F401",
|
||||
"I001",
|
||||
"RET504",
|
||||
"PLR2004",
|
||||
"W291",
|
||||
"PLW2901",
|
||||
"D213",
|
||||
"PLR0402",
|
||||
},
|
||||
},
|
||||
ruff = {
|
||||
init_options = {
|
||||
settings = {
|
||||
lint = {
|
||||
unfixable = { "F401" },
|
||||
select = {
|
||||
"ALL",
|
||||
},
|
||||
ignore = {
|
||||
"ANN",
|
||||
"COM",
|
||||
"C90",
|
||||
"DJ",
|
||||
"EXE",
|
||||
"T10",
|
||||
"TID",
|
||||
"D100",
|
||||
"D101",
|
||||
"D102",
|
||||
"D103",
|
||||
"D104",
|
||||
"D105",
|
||||
"D106",
|
||||
"D107",
|
||||
"D200",
|
||||
"D205",
|
||||
"D212",
|
||||
"D400",
|
||||
"D401",
|
||||
"D415",
|
||||
"E402",
|
||||
"E501",
|
||||
"ERA001",
|
||||
"TRY003",
|
||||
"TD002",
|
||||
"TD003",
|
||||
"T201",
|
||||
"FIX002",
|
||||
"N803",
|
||||
"PD901",
|
||||
-- "F401",
|
||||
"I001",
|
||||
"RET504",
|
||||
"PLR2004",
|
||||
"W291",
|
||||
"PLW2901",
|
||||
"D213",
|
||||
"PLR0402",
|
||||
},
|
||||
},
|
||||
|
||||
args = {},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
-- customize how language servers are attached
|
||||
handlers = {
|
||||
-- a function without a key is simply the default handler, functions take two parameters, the server name and the configured options table for that server
|
||||
-- function(server, opts) require("lspconfig")[server].setup(opts) end
|
||||
args = {},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
-- customize how language servers are attached
|
||||
handlers = {
|
||||
-- a function without a key is simply the default handler, functions take two parameters, the server name and the configured options table for that server
|
||||
-- function(server, opts) require("lspconfig")[server].setup(opts) end
|
||||
|
||||
-- the key is the server that is being setup with `lspconfig`
|
||||
-- rust_analyzer = false, -- setting a handler to false will disable the set up of that language server
|
||||
-- pyright = function(_, opts) require("lspconfig").pyright.setup(opts) end -- or a custom handler function can be passed
|
||||
},
|
||||
-- Configure buffer local auto commands to add when attaching a language server
|
||||
autocmds = {
|
||||
-- first key is the `augroup` to add the auto commands to (:h augroup)
|
||||
lsp_document_highlight = {
|
||||
-- Optional condition to create/delete auto command group
|
||||
-- can either be a string of a client capability or a function of `fun(client, bufnr): boolean`
|
||||
-- condition will be resolved for each client on each execution and if it ever fails for all clients,
|
||||
-- the auto commands will be deleted for that buffer
|
||||
cond = "textDocument/documentHighlight",
|
||||
-- cond = function(client, bufnr) return client.name == "lua_ls" end,
|
||||
-- list of auto commands to set
|
||||
{
|
||||
-- events to trigger
|
||||
event = { "CursorHold", "CursorHoldI" },
|
||||
-- the rest of the autocmd options (:h nvim_create_autocmd)
|
||||
desc = "Document Highlighting",
|
||||
callback = function()
|
||||
vim.lsp.buf.document_highlight()
|
||||
end,
|
||||
},
|
||||
{
|
||||
event = { "CursorMoved", "CursorMovedI", "BufLeave" },
|
||||
desc = "Document Highlighting Clear",
|
||||
callback = function()
|
||||
vim.lsp.buf.clear_references()
|
||||
end,
|
||||
},
|
||||
},
|
||||
-- disable inlay hints in insert mode
|
||||
disable_inlay_hints_on_insert = {
|
||||
-- only create for language servers that support inlay hints
|
||||
-- (and only if vim.lsp.inlay_hint is available)
|
||||
cond = vim.lsp.inlay_hint and "textDocument/inlayHint" or false,
|
||||
{
|
||||
-- when going into insert mode
|
||||
event = "InsertEnter",
|
||||
desc = "disable inlay hints on insert",
|
||||
callback = function(args)
|
||||
local filter = { bufnr = args.buf }
|
||||
-- if the inlay hints are currently enabled
|
||||
if vim.lsp.inlay_hint.is_enabled(filter) then
|
||||
-- disable the inlay hints
|
||||
vim.lsp.inlay_hint.enable(false, filter)
|
||||
-- create a single use autocommand to turn the inlay hints back on
|
||||
-- when leaving insert mode
|
||||
vim.api.nvim_create_autocmd("InsertLeave", {
|
||||
buffer = args.buf,
|
||||
once = true,
|
||||
callback = function()
|
||||
vim.lsp.inlay_hint.enable(true, filter)
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
-- mappings to be set up on attaching of a language server
|
||||
mappings = {
|
||||
n = {
|
||||
gh = {
|
||||
function()
|
||||
vim.lsp.buf.hover()
|
||||
end,
|
||||
desc = "Hover symbol details",
|
||||
cond = "textDocument/hover",
|
||||
},
|
||||
gl = {
|
||||
function()
|
||||
vim.diagnostic.open_float()
|
||||
end,
|
||||
desc = "Hover diagnostics",
|
||||
},
|
||||
-- a `cond` key can provided as the string of a server capability to be required to attach, or a function with `client` and `bufnr` parameters from the `on_attach` that returns a boolean
|
||||
gD = {
|
||||
function()
|
||||
vim.lsp.buf.declaration()
|
||||
end,
|
||||
desc = "Declaration of current symbol",
|
||||
cond = "textDocument/declaration",
|
||||
},
|
||||
["<Leader>uY"] = {
|
||||
function()
|
||||
require("astrolsp.toggles").buffer_semantic_tokens()
|
||||
end,
|
||||
desc = "Toggle LSP semantic highlight (buffer)",
|
||||
cond = function(client)
|
||||
return client.server_capabilities.semanticTokensProvider and vim.lsp.semantic_tokens
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
-- A custom `on_attach` function to be run after the default `on_attach` function
|
||||
-- takes two parameters `client` and `bufnr` (`:h lspconfig-setup`)
|
||||
on_attach = function(client, bufnr)
|
||||
-- this would disable semanticTokensProvider for all clients
|
||||
-- client.server_capabilities.semanticTokensProvider = nil
|
||||
-- Disable ruff_lsp hover in favor of pyright
|
||||
if client.name == "ruff_lsp" then
|
||||
client.server_capabilities.hoverProvider = false
|
||||
end
|
||||
-- the key is the server that is being setup with `lspconfig`
|
||||
-- rust_analyzer = false, -- setting a handler to false will disable the set up of that language server
|
||||
-- pyright = function(_, opts) require("lspconfig").pyright.setup(opts) end -- or a custom handler function can be passed
|
||||
},
|
||||
-- Configure buffer local auto commands to add when attaching a language server
|
||||
autocmds = {
|
||||
-- first key is the `augroup` to add the auto commands to (:h augroup)
|
||||
lsp_document_highlight = {
|
||||
-- Optional condition to create/delete auto command group
|
||||
-- can either be a string of a client capability or a function of `fun(client, bufnr): boolean`
|
||||
-- condition will be resolved for each client on each execution and if it ever fails for all clients,
|
||||
-- the auto commands will be deleted for that buffer
|
||||
cond = "textDocument/documentHighlight",
|
||||
-- cond = function(client, bufnr) return client.name == "lua_ls" end,
|
||||
-- list of auto commands to set
|
||||
{
|
||||
-- events to trigger
|
||||
event = { "CursorHold", "CursorHoldI" },
|
||||
-- the rest of the autocmd options (:h nvim_create_autocmd)
|
||||
desc = "Document Highlighting",
|
||||
callback = function()
|
||||
vim.lsp.buf.document_highlight()
|
||||
end,
|
||||
},
|
||||
{
|
||||
event = { "CursorMoved", "CursorMovedI", "BufLeave" },
|
||||
desc = "Document Highlighting Clear",
|
||||
callback = function()
|
||||
vim.lsp.buf.clear_references()
|
||||
end,
|
||||
},
|
||||
},
|
||||
-- disable inlay hints in insert mode
|
||||
disable_inlay_hints_on_insert = {
|
||||
-- only create for language servers that support inlay hints
|
||||
-- (and only if vim.lsp.inlay_hint is available)
|
||||
cond = vim.lsp.inlay_hint and "textDocument/inlayHint" or false,
|
||||
{
|
||||
-- when going into insert mode
|
||||
event = "InsertEnter",
|
||||
desc = "disable inlay hints on insert",
|
||||
callback = function(args)
|
||||
local filter = { bufnr = args.buf }
|
||||
-- if the inlay hints are currently enabled
|
||||
if vim.lsp.inlay_hint.is_enabled(filter) then
|
||||
-- disable the inlay hints
|
||||
vim.lsp.inlay_hint.enable(false, filter)
|
||||
-- create a single use autocommand to turn the inlay hints back on
|
||||
-- when leaving insert mode
|
||||
vim.api.nvim_create_autocmd("InsertLeave", {
|
||||
buffer = args.buf,
|
||||
once = true,
|
||||
callback = function()
|
||||
vim.lsp.inlay_hint.enable(true, filter)
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
-- mappings to be set up on attaching of a language server
|
||||
mappings = {
|
||||
n = {
|
||||
gh = {
|
||||
function()
|
||||
vim.lsp.buf.hover()
|
||||
end,
|
||||
desc = "Hover symbol details",
|
||||
cond = "textDocument/hover",
|
||||
},
|
||||
gl = {
|
||||
function()
|
||||
vim.diagnostic.open_float()
|
||||
end,
|
||||
desc = "Hover diagnostics",
|
||||
},
|
||||
-- a `cond` key can provided as the string of a server capability to be required to attach, or a function with `client` and `bufnr` parameters from the `on_attach` that returns a boolean
|
||||
gD = {
|
||||
function()
|
||||
vim.lsp.buf.declaration()
|
||||
end,
|
||||
desc = "Declaration of current symbol",
|
||||
cond = "textDocument/declaration",
|
||||
},
|
||||
["<Leader>uY"] = {
|
||||
function()
|
||||
require("astrolsp.toggles").buffer_semantic_tokens()
|
||||
end,
|
||||
desc = "Toggle LSP semantic highlight (buffer)",
|
||||
cond = function(client)
|
||||
return client.server_capabilities.semanticTokensProvider and vim.lsp.semantic_tokens
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
-- A custom `on_attach` function to be run after the default `on_attach` function
|
||||
-- takes two parameters `client` and `bufnr` (`:h lspconfig-setup`)
|
||||
on_attach = function(client, bufnr)
|
||||
-- this would disable semanticTokensProvider for all clients
|
||||
-- client.server_capabilities.semanticTokensProvider = nil
|
||||
-- Disable ruff_lsp hover in favor of pyright
|
||||
if client.name == "ruff_lsp" then
|
||||
client.server_capabilities.hoverProvider = false
|
||||
end
|
||||
|
||||
-- Disable completion feature of pyright
|
||||
if client.name == "basedpyright" then
|
||||
client.server_capabilities.completionProvider = false
|
||||
end
|
||||
end,
|
||||
},
|
||||
-- Disable completion feature of pyright
|
||||
if client.name == "basedpyright" then
|
||||
client.server_capabilities.completionProvider = false
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user