mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-04-27 03:47:37 +00:00
Merge pull request #1479 from snoweuph/feat/vue
Some checks are pending
Set up binary cache / cachix (default) (push) Waiting to run
Set up binary cache / cachix (maximal) (push) Waiting to run
Set up binary cache / cachix (nix) (push) Waiting to run
Treewide Checks / Validate flake (push) Waiting to run
Treewide Checks / Check formatting (push) Waiting to run
Treewide Checks / Check source tree for typos (push) Waiting to run
Treewide Checks / Validate documentation builds (push) Waiting to run
Treewide Checks / Validate documentation builds-1 (push) Waiting to run
Treewide Checks / Validate documentation builds-2 (push) Waiting to run
Treewide Checks / Validate documentation builds-3 (push) Waiting to run
Treewide Checks / Validate hyperlinks in documentation sources (push) Waiting to run
Treewide Checks / Validate Editorconfig conformance (push) Waiting to run
Build and deploy documentation / Check latest commit (push) Waiting to run
Build and deploy documentation / publish (push) Blocked by required conditions
Some checks are pending
Set up binary cache / cachix (default) (push) Waiting to run
Set up binary cache / cachix (maximal) (push) Waiting to run
Set up binary cache / cachix (nix) (push) Waiting to run
Treewide Checks / Validate flake (push) Waiting to run
Treewide Checks / Check formatting (push) Waiting to run
Treewide Checks / Check source tree for typos (push) Waiting to run
Treewide Checks / Validate documentation builds (push) Waiting to run
Treewide Checks / Validate documentation builds-1 (push) Waiting to run
Treewide Checks / Validate documentation builds-2 (push) Waiting to run
Treewide Checks / Validate documentation builds-3 (push) Waiting to run
Treewide Checks / Validate hyperlinks in documentation sources (push) Waiting to run
Treewide Checks / Validate Editorconfig conformance (push) Waiting to run
Build and deploy documentation / Check latest commit (push) Waiting to run
Build and deploy documentation / publish (push) Blocked by required conditions
languages/vue: init
This commit is contained in:
commit
e63dc282c1
7 changed files with 281 additions and 0 deletions
|
|
@ -104,6 +104,7 @@ isMaximal: {
|
||||||
qml.enable = false;
|
qml.enable = false;
|
||||||
jinja.enable = false;
|
jinja.enable = false;
|
||||||
svelte.enable = false;
|
svelte.enable = false;
|
||||||
|
vue.enable = false;
|
||||||
liquid.enable = false;
|
liquid.enable = false;
|
||||||
tera.enable = false;
|
tera.enable = false;
|
||||||
twig.enable = false;
|
twig.enable = false;
|
||||||
|
|
|
||||||
|
|
@ -290,6 +290,11 @@
|
||||||
- Added {option}`vim.lsp.presets.angular-language-server.enable` for Angular
|
- Added {option}`vim.lsp.presets.angular-language-server.enable` for Angular
|
||||||
Template support.
|
Template support.
|
||||||
|
|
||||||
|
- Added {option}`vim.lsp.presets.vtsls.enable` for Vue TypeScript support.
|
||||||
|
|
||||||
|
- Added {option}`vim.lsp.presets.vue-language-server.enable` for Vue Template
|
||||||
|
support.
|
||||||
|
|
||||||
- Fix `vim.lsp.presets.vala-language-server` to be wrapped correctly with
|
- Fix `vim.lsp.presets.vala-language-server` to be wrapped correctly with
|
||||||
`uncrustify`.
|
`uncrustify`.
|
||||||
|
|
||||||
|
|
@ -356,6 +361,8 @@
|
||||||
- Added [`biomejs`](https://biomejs.dev/) as extra diagnostics provider to
|
- Added [`biomejs`](https://biomejs.dev/) as extra diagnostics provider to
|
||||||
`languages.ts`.
|
`languages.ts`.
|
||||||
|
|
||||||
|
- Added `languages.vue`.
|
||||||
|
|
||||||
- Add `languages.fluent` using the official plugin. This only provides
|
- Add `languages.fluent` using the official plugin. This only provides
|
||||||
highlighting.
|
highlighting.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ in {
|
||||||
./scala.nix
|
./scala.nix
|
||||||
./sql.nix
|
./sql.nix
|
||||||
./svelte.nix
|
./svelte.nix
|
||||||
|
./vue.nix
|
||||||
./terraform.nix
|
./terraform.nix
|
||||||
./toml.nix
|
./toml.nix
|
||||||
./typescript.nix
|
./typescript.nix
|
||||||
|
|
|
||||||
151
modules/plugins/languages/vue.nix
Normal file
151
modules/plugins/languages/vue.nix
Normal file
|
|
@ -0,0 +1,151 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (builtins) attrNames;
|
||||||
|
inherit (lib.options) mkEnableOption mkOption literalExpression;
|
||||||
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
inherit (lib) genAttrs;
|
||||||
|
inherit (lib.meta) getExe;
|
||||||
|
inherit (lib.types) enum listOf;
|
||||||
|
inherit (lib.nvim.types) mkGrammarOption diagnostics;
|
||||||
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
|
||||||
|
cfg = config.vim.languages.vue;
|
||||||
|
|
||||||
|
defaultServers = ["vue-language-server" "vtsls"];
|
||||||
|
servers = ["vue-language-server" "vtsls" "typescript-language-server"];
|
||||||
|
|
||||||
|
defaultFormat = ["biome" "biome-check" "biome-organize-imports"];
|
||||||
|
formats = {
|
||||||
|
biome = {
|
||||||
|
command = getExe pkgs.biome;
|
||||||
|
};
|
||||||
|
|
||||||
|
biome-check = {
|
||||||
|
command = getExe pkgs.biome;
|
||||||
|
};
|
||||||
|
|
||||||
|
biome-organize-imports = {
|
||||||
|
command = getExe pkgs.biome;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
defaultDiagnosticsProvider = ["biomejs"];
|
||||||
|
diagnosticsProviders = {
|
||||||
|
biomejs = let
|
||||||
|
pkg = pkgs.biome;
|
||||||
|
in {
|
||||||
|
package = pkg;
|
||||||
|
config = {
|
||||||
|
cmd = getExe pkg;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
options.vim.languages.vue = {
|
||||||
|
enable = mkEnableOption "Vue.js language support";
|
||||||
|
|
||||||
|
treesitter = {
|
||||||
|
enable =
|
||||||
|
mkEnableOption "Vue.js treesitter"
|
||||||
|
// {
|
||||||
|
default = config.vim.languages.enableTreesitter;
|
||||||
|
defaultText = literalExpression "config.vim.languages.enableTreesitter";
|
||||||
|
};
|
||||||
|
|
||||||
|
package = mkGrammarOption pkgs "vue";
|
||||||
|
};
|
||||||
|
|
||||||
|
lsp = {
|
||||||
|
enable =
|
||||||
|
mkEnableOption "Vue.js LSP support"
|
||||||
|
// {
|
||||||
|
default = config.vim.lsp.enable;
|
||||||
|
defaultText = literalExpression "config.vim.lsp.enable";
|
||||||
|
};
|
||||||
|
|
||||||
|
servers = mkOption {
|
||||||
|
type = listOf (enum servers);
|
||||||
|
default = defaultServers;
|
||||||
|
description = "Vue.js LSP server to use";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
format = {
|
||||||
|
enable =
|
||||||
|
mkEnableOption "Vue.js formatting"
|
||||||
|
// {
|
||||||
|
default = config.vim.languages.enableFormat;
|
||||||
|
defaultText = literalExpression "config.vim.languages.enableFormat";
|
||||||
|
};
|
||||||
|
|
||||||
|
type = mkOption {
|
||||||
|
type = listOf (enum (attrNames formats));
|
||||||
|
default = defaultFormat;
|
||||||
|
description = "Vue.js formatter to use.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
extraDiagnostics = {
|
||||||
|
enable =
|
||||||
|
mkEnableOption "extra Vue.js diagnostics"
|
||||||
|
// {
|
||||||
|
default = config.vim.languages.enableExtraDiagnostics;
|
||||||
|
defaultText = literalExpression "config.vim.languages.enableExtraDiagnostics";
|
||||||
|
};
|
||||||
|
|
||||||
|
types = diagnostics {
|
||||||
|
langDesc = "Vue.js";
|
||||||
|
inherit diagnosticsProviders;
|
||||||
|
inherit defaultDiagnosticsProvider;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable (mkMerge [
|
||||||
|
(mkIf cfg.treesitter.enable {
|
||||||
|
vim.treesitter.enable = true;
|
||||||
|
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.lsp.enable {
|
||||||
|
vim.lsp = {
|
||||||
|
presets = genAttrs cfg.lsp.servers (_: {enable = true;});
|
||||||
|
servers = genAttrs cfg.lsp.servers (_: {
|
||||||
|
filetypes = ["vue"];
|
||||||
|
});
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.format.enable {
|
||||||
|
vim.formatter.conform-nvim = {
|
||||||
|
enable = true;
|
||||||
|
setupOpts = {
|
||||||
|
formatters_by_ft.vue = cfg.format.type;
|
||||||
|
formatters =
|
||||||
|
mapListToAttrs (name: {
|
||||||
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.extraDiagnostics.enable {
|
||||||
|
vim.diagnostics.nvim-lint = {
|
||||||
|
enable = true;
|
||||||
|
linters_by_ft.vue = cfg.extraDiagnostics.types;
|
||||||
|
linters = mkMerge (
|
||||||
|
map (name: {
|
||||||
|
${name}.cmd = getExe diagnosticsProviders.${name}.package;
|
||||||
|
})
|
||||||
|
cfg.extraDiagnostics.types
|
||||||
|
);
|
||||||
|
};
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
@ -68,6 +68,8 @@
|
||||||
./vala-language-server.nix
|
./vala-language-server.nix
|
||||||
./vscode-css-language-server.nix
|
./vscode-css-language-server.nix
|
||||||
./vscode-json-language-server.nix
|
./vscode-json-language-server.nix
|
||||||
|
./vtsls.nix
|
||||||
|
./vue-language-server.nix
|
||||||
./wgsl-analyzer.nix
|
./wgsl-analyzer.nix
|
||||||
./yaml-language-server.nix
|
./yaml-language-server.nix
|
||||||
./zls.nix
|
./zls.nix
|
||||||
|
|
|
||||||
37
modules/plugins/lsp/presets/vtsls.nix
Normal file
37
modules/plugins/lsp/presets/vtsls.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.meta) getExe;
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.nvim.types) mkLspPresetEnableOption;
|
||||||
|
|
||||||
|
cfg = config.vim.lsp.presets.vtsls;
|
||||||
|
in {
|
||||||
|
options.vim.lsp.presets.vtsls = {
|
||||||
|
enable = mkLspPresetEnableOption "vtsls" "Vue.js Typescript" [];
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
vim.lsp.servers.vtsls = {
|
||||||
|
enable = true;
|
||||||
|
cmd = [(getExe pkgs.vtsls) "--stdio"];
|
||||||
|
root_markers = [".git" "tsconfig.json" "package.json"];
|
||||||
|
settings = {
|
||||||
|
vtsls = {
|
||||||
|
tsserver.globalPlugins = [
|
||||||
|
{
|
||||||
|
name = "@vue/typescript-plugin";
|
||||||
|
location = "${pkgs.vue-language-server}/lib/language-tools/packages/language-server";
|
||||||
|
languages = ["vue"];
|
||||||
|
configNamespace = "typescript";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
capabilities.semanticTokensProvider = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
82
modules/plugins/lsp/presets/vue-language-server.nix
Normal file
82
modules/plugins/lsp/presets/vue-language-server.nix
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.meta) getExe;
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.options) mkEnableOption;
|
||||||
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
|
||||||
|
cfg = config.vim.lsp.presets.vue-language-server;
|
||||||
|
in {
|
||||||
|
options.vim.lsp.presets.vue-language-server = {
|
||||||
|
enable = mkEnableOption ''
|
||||||
|
the Vue.js Language Server.
|
||||||
|
|
||||||
|
This LSP doesn't work standalone and requires either
|
||||||
|
{option}`vim.lsp.presets.vtsls.enable`
|
||||||
|
or
|
||||||
|
{option}`vim.lsp.presets.typescript-language-server.enable`
|
||||||
|
to work as expected.
|
||||||
|
|
||||||
|
Default `filetypes = ${lib.generators.toPretty {} []}`. \
|
||||||
|
Use {option}`vim.lsp.servers.vue-language-server` for customization
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
vim.lsp.servers.vue-language-server = {
|
||||||
|
enable = true;
|
||||||
|
cmd = [(getExe pkgs.vue-language-server) "--stdio"];
|
||||||
|
root_markers = [".git" "tsconfig.json" "package.json"];
|
||||||
|
on_init =
|
||||||
|
mkLuaInline
|
||||||
|
# This LSP doesn't work standalone and requires a TypeScripts LSP to work.
|
||||||
|
# It can work with `typescript-language-server`, but it is not great, thus we prefer `vtsls`
|
||||||
|
''
|
||||||
|
function(client)
|
||||||
|
retries = 0
|
||||||
|
local function typescriptHandler(_, result, context)
|
||||||
|
local function getLSP(name)
|
||||||
|
return vim.lsp.get_clients({ bufnr = context.bufnr, name = name})[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
local typescipt_lsp = getLSP('vtsls') or getLSP('typescript-language-server')
|
||||||
|
if not typescipt_lsp then
|
||||||
|
if retries <= 10 then
|
||||||
|
retries = retries + 1
|
||||||
|
vim.defer_fn(function()
|
||||||
|
typescriptHandler(_, result, context)
|
||||||
|
end, 100)
|
||||||
|
else
|
||||||
|
vim.notify(
|
||||||
|
'Could not find `vtsls`, `typescript-language-server`, or `typescript-go` lsp, required by `vue-language-server`.',
|
||||||
|
vim.log.levels.ERROR
|
||||||
|
)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local param = unpack(result)
|
||||||
|
local id, command, payload = unpack(param)
|
||||||
|
typescipt_lsp:exec_cmd({
|
||||||
|
title = 'vue-language-server-forwarded',
|
||||||
|
command = 'typescript.tsserverRequest',
|
||||||
|
arguments = {
|
||||||
|
command,
|
||||||
|
payload,
|
||||||
|
},
|
||||||
|
}, { bufnr = context.bufnr }, function(_, r)
|
||||||
|
local response_data = { { id, r and r.body } }
|
||||||
|
client:notify('tsserver/response', response_data)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
client.handlers['tsserver/request'] = typescriptHandler
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue