aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lsp/ast_grep.lua
diff options
context:
space:
mode:
authorawy <awy@awy.one>2025-10-20 20:55:26 +0300
committerawy <awy@awy.one>2025-10-20 20:55:26 +0300
commit662dafc52b2c8a9426bb2197ab9246a8cda318e4 (patch)
treef9d1f20e3864360bf941fd6bc02848ed77b037a8 /.config/nvim/lsp/ast_grep.lua
parent8131d9f2898b991a2d2c7a2ac601ce9e07cc9c9f (diff)
downloadhyprdots-662dafc52b2c8a9426bb2197ab9246a8cda318e4.tar.gz
nvqw
Diffstat (limited to '.config/nvim/lsp/ast_grep.lua')
-rw-r--r--.config/nvim/lsp/ast_grep.lua50
1 files changed, 50 insertions, 0 deletions
diff --git a/.config/nvim/lsp/ast_grep.lua b/.config/nvim/lsp/ast_grep.lua
new file mode 100644
index 0000000..0cf9e72
--- /dev/null
+++ b/.config/nvim/lsp/ast_grep.lua
@@ -0,0 +1,50 @@
+---@brief
+---
+--- https://ast-grep.github.io/
+---
+--- ast-grep(sg) is a fast and polyglot tool for code structural search, lint, rewriting at large scale.
+--- ast-grep LSP only works in projects that have `sgconfig.y[a]ml` in their root directories.
+--- ```sh
+--- npm install [-g] @ast-grep/cli
+--- ```
+
+---@type vim.lsp.Config
+return {
+ cmd = { 'ast-grep', 'lsp' },
+ workspace_required = true,
+ reuse_client = function(client, config)
+ config.cmd_cwd = config.root_dir
+ return client.config.cmd_cwd == config.cmd_cwd
+ end,
+ filetypes = { -- https://ast-grep.github.io/reference/languages.html
+ 'bash',
+ 'c',
+ 'cpp',
+ 'csharp',
+ 'css',
+ 'elixir',
+ 'go',
+ 'haskell',
+ 'html',
+ 'java',
+ 'javascript',
+ 'javascriptreact',
+ 'javascript.jsx',
+ 'json',
+ 'kotlin',
+ 'lua',
+ 'nix',
+ 'php',
+ 'python',
+ 'ruby',
+ 'rust',
+ 'scala',
+ 'solidity',
+ 'swift',
+ 'typescript',
+ 'typescriptreact',
+ 'typescript.tsx',
+ 'yaml',
+ },
+ root_markers = { 'sgconfig.yaml', 'sgconfig.yml' },
+}