feat(plugins): replace scooter find‑replace with grug‑far and add Python interpreter resolution
This commit is contained in:
1 parent
28bd9b89f5
commit
77b718c77f
7 files changed
+203
-337
No files matched your search
+55
-89
@@ -1,104 +1,70 @@
|
||||
if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
|
||||
--- AstroLSP: the configuration that should only exist while a language server
|
||||
--- is attached (`:h astrolsp`). Every mapping carries a `cond` — a server
|
||||
--- method name — so it is created buffer-locally on attach and is simply
|
||||
--- absent (including in which-key) wherever no server advertises it, instead
|
||||
--- of being a global bind that errors or silently does nothing.
|
||||
---
|
||||
--- Deliberately configured elsewhere:
|
||||
--- * per-server settings: basedpyright interpreter resolution lives in
|
||||
--- plugins/python.lua, the language packs in community.lua own the rest
|
||||
--- * formatting: conform owns it end to end. The astrocommunity conform
|
||||
--- pack sets `formatting.disabled = true` here, and the pre-save code
|
||||
--- action pass hangs off conform's `format_on_save` hook so its order
|
||||
--- relative to formatting is deterministic (plugins/conform.lua)
|
||||
--- * diagnostics jumps/pickers (`J`, `K`, `<C-a>d`) and everything else that
|
||||
--- works without a server: plugins/astrocore.lua
|
||||
--- @module plugins.astrolsp
|
||||
|
||||
-- AstroLSP allows you to customize the features in AstroNvim's LSP configuration engine
|
||||
-- Configuration documentation can be found with `:h astrolsp`
|
||||
-- NOTE: We highly recommend setting up the Lua Language Server (`:LspInstall lua_ls`)
|
||||
-- as this provides autocomplete and documentation while editing
|
||||
--- @param source string snacks.picker source
|
||||
--- @return function
|
||||
local function trouble_picker(source)
|
||||
return function() require("config.picker").with_trouble(source) end
|
||||
end
|
||||
|
||||
---@type LazySpec
|
||||
return {
|
||||
"AstroNvim/astrolsp",
|
||||
---@type AstroLSPOpts
|
||||
opts = {
|
||||
-- Configuration table of features provided by AstroLSP
|
||||
features = {
|
||||
codelens = true, -- 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 = {
|
||||
-- control auto formatting on save
|
||||
format_on_save = {
|
||||
enabled = true, -- enable or disable format on save globally
|
||||
allow_filetypes = { -- enable format on save for specified filetypes only
|
||||
-- "go",
|
||||
},
|
||||
ignore_filetypes = { -- disable format on save for specified filetypes
|
||||
-- "python",
|
||||
},
|
||||
},
|
||||
disabled = { -- disable formatting capabilities for the listed language servers
|
||||
-- disable lua_ls formatting capability if you want to use StyLua to format your lua code
|
||||
-- "lua_ls",
|
||||
},
|
||||
timeout_ms = 1000, -- default format timeout
|
||||
-- filter = function(client) -- fully override the default formatting function
|
||||
-- return true
|
||||
-- end
|
||||
},
|
||||
-- enable servers that you already have installed without mason
|
||||
servers = {
|
||||
-- "pyright"
|
||||
},
|
||||
-- customize language server configuration passed to `vim.lsp.config`
|
||||
-- client specific configuration can also go in `lsp/` in your configuration root (see `:h lsp-config`)
|
||||
config = {
|
||||
-- ["*"] = { capabilities = {} }, -- modify default LSP client settings such as capabilities
|
||||
},
|
||||
-- customize how language servers are attached
|
||||
handlers = {
|
||||
-- a function with the key `*` modifies the default handler, functions takes the server name as the parameter
|
||||
-- ["*"] = function(server) vim.lsp.enable(server) end
|
||||
|
||||
-- the key is the server that is being setup with `vim.lsp.config`
|
||||
-- rust_analyzer = false, -- setting a handler to false will disable the set up of that language server
|
||||
},
|
||||
-- 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_codelens_refresh = {
|
||||
-- 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/codeLens",
|
||||
-- cond = function(client, bufnr) return client.name == "lua_ls" end,
|
||||
-- list of auto commands to set
|
||||
{
|
||||
-- events to trigger
|
||||
event = { "InsertLeave", "BufEnter" },
|
||||
-- the rest of the autocmd options (:h nvim_create_autocmd)
|
||||
desc = "Refresh codelens (buffer)",
|
||||
callback = function(args)
|
||||
if require("astrolsp").config.features.codelens then vim.lsp.codelens.enable(true, { bufnr = args.buf }) end
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
-- mappings to be set up on attaching of a language server
|
||||
mappings = {
|
||||
n = {
|
||||
-- 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",
|
||||
-- snacks.words auto-highlights the references of the symbol under the
|
||||
-- cursor (`words` in plugins/user.lua); these cycle through them,
|
||||
-- complementing the core astrolsp `gd` / `gr` binds
|
||||
["]]"] = {
|
||||
function() require("snacks").words.jump(vim.v.count1, true) end,
|
||||
desc = "Next reference",
|
||||
cond = "textDocument/documentHighlight",
|
||||
},
|
||||
["<Leader>uY"] = {
|
||||
function() require("astrolsp.toggles").buffer_semantic_tokens() end,
|
||||
desc = "Toggle LSP semantic highlight (buffer)",
|
||||
cond = function(client)
|
||||
return client:supports_method "textDocument/semanticTokens/full" and vim.lsp.semantic_tokens ~= nil
|
||||
end,
|
||||
["[["] = {
|
||||
function() require("snacks").words.jump(-vim.v.count1, true) end,
|
||||
desc = "Previous reference",
|
||||
cond = "textDocument/documentHighlight",
|
||||
},
|
||||
|
||||
-- <C-a>: assist. Code actions and symbol search, each with the
|
||||
-- trouble.nvim hand-off on <C-t> where a picker is involved.
|
||||
["<C-a>a"] = {
|
||||
function() vim.lsp.buf.code_action() end,
|
||||
desc = "Show code actions",
|
||||
cond = "textDocument/codeAction",
|
||||
},
|
||||
["<C-a>s"] = {
|
||||
trouble_picker "lsp_symbols",
|
||||
desc = "Search LSP symbols (<C-t> sends to Trouble)",
|
||||
cond = "textDocument/documentSymbol",
|
||||
},
|
||||
["<C-a>S"] = {
|
||||
trouble_picker "lsp_workspace_symbols",
|
||||
desc = "Search LSP workspace symbols (<C-t> sends to Trouble)",
|
||||
cond = "workspace/symbol",
|
||||
},
|
||||
["<C-f><C-f>"] = {
|
||||
function() require("snacks").picker.lsp_symbols { layout = { preset = "vscode", preview = "main" } } end,
|
||||
desc = "Find LSP symbols",
|
||||
cond = "textDocument/documentSymbol",
|
||||
},
|
||||
},
|
||||
},
|
||||
-- A custom `on_attach` function to be run after the default `on_attach` function
|
||||
-- takes two parameters `client` and `bufnr` (`:h lsp-attach`)
|
||||
on_attach = function(client, bufnr)
|
||||
-- this would disable semanticTokensProvider for all clients
|
||||
-- client.server_capabilities.semanticTokensProvider = nil
|
||||
end,
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user