diff options
| author | Riley Bruins <ribru17@hotmail.com> | 2025-09-06 12:51:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-06 12:51:26 -0700 |
| commit | 260d5793b197fccddb8a671f9020c829725921b0 (patch) | |
| tree | 62b1c633183e79b92b55205f62d75981738b8eca /lsp | |
| parent | docs: update configs.md (diff) | |
| download | nvim-lspconfig-260d5793b197fccddb8a671f9020c829725921b0.tar nvim-lspconfig-260d5793b197fccddb8a671f9020c829725921b0.tar.gz nvim-lspconfig-260d5793b197fccddb8a671f9020c829725921b0.tar.bz2 nvim-lspconfig-260d5793b197fccddb8a671f9020c829725921b0.tar.lz nvim-lspconfig-260d5793b197fccddb8a671f9020c829725921b0.tar.xz nvim-lspconfig-260d5793b197fccddb8a671f9020c829725921b0.tar.zst nvim-lspconfig-260d5793b197fccddb8a671f9020c829725921b0.zip | |
fix(ts_query_ls): root pattern fixup, override query ftplugin opts #4059
**Problem:** The built-in query linter will cause duplicate diagnostics
when running the query LSP. It is also slower and blocking, and can
cause jarring editor freezes for short times.
**Solution:** Disable it when using `ts_query_ls`. Also, set the
omnifunc to the LSP omnifunc rather than the custom `query` one.
Diffstat (limited to 'lsp')
| -rw-r--r-- | lsp/ts_query_ls.lua | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/lsp/ts_query_ls.lua b/lsp/ts_query_ls.lua index 25f966c2..665b2d8d 100644 --- a/lsp/ts_query_ls.lua +++ b/lsp/ts_query_ls.lua @@ -4,38 +4,40 @@ --- Can be configured by passing a "settings" object to `vim.lsp.config('ts_query_ls', {})`: --- ```lua --- vim.lsp.config('ts_query_ls', { ---- settings = { ---- parser_install_directories = { ---- -- If using nvim-treesitter with lazy.nvim ---- vim.fs.joinpath( ---- vim.fn.stdpath('data'), ---- '/lazy/nvim-treesitter/parser/' ---- ), ---- }, ---- -- This setting is provided by default ---- parser_aliases = { ---- ecma = 'javascript', ---- jsx = 'javascript', ---- php_only = 'php', ---- }, ---- -- E.g. zed support ---- language_retrieval_patterns = { ---- 'languages/src/([^/]+)/[^/]+\\.scm$', ---- }, +--- init_options = { +--- parser_install_directories = { +--- '/my/parser/install/dir', --- }, +--- -- This setting is provided by default +--- parser_aliases = { +--- ecma = 'javascript', +--- jsx = 'javascript', +--- php_only = 'php', +--- }, +--- }, --- }) --- ``` +-- Disable the (slow) built-in query linter, which will show duplicate diagnostics. This must be done before the query +-- ftplugin is sourced. +vim.g.query_lint_on = {} + ---@type vim.lsp.Config return { cmd = { 'ts_query_ls' }, filetypes = { 'query' }, - root_markers = { 'queries', '.git' }, - settings = { + root_markers = { '.tsqueryrc.json', '.git' }, + init_options = { parser_aliases = { ecma = 'javascript', jsx = 'javascript', php_only = 'php', }, + parser_install_directories = { + vim.fn.stdpath('data') .. '/site/parser', + }, }, + on_attach = function(_, buf) + vim.bo[buf].omnifunc = 'v:lua.vim.lsp.omnifunc' + end, } |
