-
-
Notifications
You must be signed in to change notification settings - Fork 216
languages/ts: add vtsls support for vue #1322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,8 +66,43 @@ | |
| end | ||
| ''; | ||
| }; | ||
| vtsls = { | ||
| cmd = [(getExe pkgs.vtsls) "--stdio"]; | ||
| filetypes = [ | ||
| "javascript" | ||
| "javascriptreact" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thats a react filetype not vue. |
||
| "javascript.jsx" | ||
| "typescript" | ||
| "typescriptreact" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thats a react filetype not vue. |
||
| "typescript.tsx" | ||
| "vue" | ||
| ]; | ||
| root_markers = ["tsconfig.json" "jsconfig.json" "package.json" ".git"]; | ||
| settings = { | ||
| vtsls = { | ||
| tsserver.globalPlugins = [ | ||
| { | ||
| name = "@vue/typescript-plugin"; | ||
| location = "${lib.getBin pkgs.vue-language-server}/lib/language-tools/packages/language-server"; | ||
| languages = ["vue"]; | ||
| configNamespace = "typescript"; | ||
| } | ||
| ]; | ||
| }; | ||
| }; | ||
| on_attach = mkLuaInline '' | ||
| function(client, bufnr) | ||
| -- Disable semantic tokens for Vue files to prevent highlighting conflicts | ||
| if vim.bo[bufnr].filetype == 'vue' then | ||
| client.server_capabilities.semanticTokensProvider = nil | ||
| else | ||
| client.server_capabilities.semanticTokensProvider.full = true | ||
| end | ||
| end | ||
| ''; | ||
| }; | ||
| in { | ||
| inherit ts_ls; | ||
| inherit ts_ls vtsls; | ||
| # Here for backwards compatibility. Still consider tsserver a valid | ||
| # configuration in the enum, but assert if it's set to *properly* | ||
| # redirect the user to the correct server. | ||
|
|
@@ -213,12 +248,14 @@ in { | |
| _file = ./ts.nix; | ||
| options.vim.languages.ts = { | ||
| enable = mkEnableOption "Typescript/Javascript language support"; | ||
| extraVueSupport = mkEnableOption "Vue support for vtsls"; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @NotAShelf should vue be in it's own language module? since astro/svelte has their own There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the main argument for having it in the typescript model is because: "Since v3.0.0, the Vue language server requires Both astro and svelte have their standalone LSPs because they deviate from regular ts / tsx so much.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For start this should be moved into Side Info: I plan to split the react stuff out of the ts module into its own in the futre as well, now that we can easly reuse LSPs across modules. |
||
|
|
||
| treesitter = { | ||
| enable = mkEnableOption "Typescript/Javascript treesitter" // {default = config.vim.languages.enableTreesitter;}; | ||
| tsPackage = mkGrammarOption pkgs "typescript"; | ||
| tsxPackage = mkGrammarOption pkgs "tsx"; | ||
| jsPackage = mkGrammarOption pkgs "javascript"; | ||
| vuePackage = mkGrammarOption pkgs "vue"; | ||
| }; | ||
|
|
||
| lsp = { | ||
|
|
@@ -275,11 +312,13 @@ in { | |
| config = mkIf cfg.enable (mkMerge [ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there should probably be a |
||
| (mkIf cfg.treesitter.enable { | ||
| vim.treesitter.enable = true; | ||
| vim.treesitter.grammars = [ | ||
| cfg.treesitter.tsPackage | ||
| cfg.treesitter.tsxPackage | ||
| cfg.treesitter.jsPackage | ||
| ]; | ||
| vim.treesitter.grammars = | ||
| [ | ||
| cfg.treesitter.tsPackage | ||
| cfg.treesitter.tsxPackage | ||
| cfg.treesitter.jsPackage | ||
| ] | ||
| ++ lib.optional cfg.extraVueSupport cfg.treesitter.vuePackage; | ||
| }) | ||
|
|
||
| (mkIf cfg.lsp.enable { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be moved into lsp/presets/vtsls