mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-06-10 07:00:00 +00:00
Merge branch 'main' into doc-lsp-cleanup
This commit is contained in:
commit
588e595fc1
7 changed files with 285 additions and 39 deletions
|
|
@ -108,6 +108,7 @@ isMaximal: {
|
|||
jinja.enable = false;
|
||||
svelte.enable = false;
|
||||
vue.enable = false;
|
||||
tsx.enable = false;
|
||||
liquid.enable = false;
|
||||
tera.enable = false;
|
||||
twig.enable = false;
|
||||
|
|
|
|||
|
|
@ -118,6 +118,10 @@
|
|||
SCSS/SASS. This also changes the default LSP to `some-sass-language-server`
|
||||
for SCSS/SASS.
|
||||
|
||||
- Split React/TSX from `languages.typescript` into `languages.tsx`. This new
|
||||
module provides jsx/tsx support. This is a step of cleaning up the Typescript
|
||||
module for the future.
|
||||
|
||||
[CaueAnjos](https://github.com/caueanjos)
|
||||
|
||||
- Renamed `roslyn_ls` to `roslyn-ls`
|
||||
|
|
@ -402,6 +406,8 @@
|
|||
|
||||
- Added `asmfmt` and `nasmfmt` formatters to `languages.asm`.
|
||||
|
||||
- Added `astyle`, `indent` and `clang-format` to `languages.clang` formatters.
|
||||
|
||||
- Added `biome-check` and `biome-organize-imports` formatters to `languages.ts`.
|
||||
|
||||
- Added [`biomejs`](https://biomejs.dev/) as extra diagnostics provider to
|
||||
|
|
|
|||
|
|
@ -373,5 +373,10 @@ in {
|
|||
<https://strongly-typed-thoughts.net/blog/final-bye-github>
|
||||
'')
|
||||
]
|
||||
|
||||
# 2026-05-16
|
||||
[
|
||||
(mkRenamedOptionModule ["vim" "languages" "typescript" "treesitter" "tsxPackage"] ["vim" "languages" "tsx" "treesitter" "package"])
|
||||
]
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,12 @@
|
|||
inherit (lib.options) mkEnableOption mkOption literalExpression;
|
||||
inherit (lib.types) bool enum package listOf;
|
||||
inherit (lib) genAttrs;
|
||||
inherit (lib.meta) getExe getExe';
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.dag) entryAfter;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
|
||||
cfg = config.vim.languages.clang;
|
||||
|
||||
|
|
@ -45,6 +48,54 @@
|
|||
'';
|
||||
};
|
||||
};
|
||||
|
||||
defaultFormat = ["clang-format"];
|
||||
formats = {
|
||||
astyle = {
|
||||
command = getExe pkgs.astyle;
|
||||
stdin = false;
|
||||
args = mkLuaInline ''
|
||||
function(self, ctx)
|
||||
local args = {
|
||||
"$FILENAME",
|
||||
}
|
||||
|
||||
if not vim.bo[ctx.buf].expandtab then
|
||||
table.insert(args, "--indent=tab=" .. ctx.shiftwidth)
|
||||
else
|
||||
table.insert(args, "--indent=spaces=" .. ctx.shiftwidth)
|
||||
end
|
||||
|
||||
return args
|
||||
end
|
||||
'';
|
||||
};
|
||||
indent = {
|
||||
command = getExe pkgs.indent;
|
||||
stdin = true;
|
||||
args = mkLuaInline ''
|
||||
function(self, ctx)
|
||||
local args = {
|
||||
"--indent-level", ctx.shiftwidth,
|
||||
"--tab-size", ctx.shiftwidth,
|
||||
}
|
||||
|
||||
if not vim.bo[ctx.buf].expandtab then
|
||||
table.insert(args, "--use-tabs")
|
||||
else
|
||||
table.insert(args, "--no-tabs")
|
||||
end
|
||||
|
||||
return args
|
||||
end
|
||||
'';
|
||||
# Default is GNU style. Nobody likes that one.
|
||||
# This is under `append_args`, to allow easy editing of this argument,
|
||||
# without having to redefine everything as a user.
|
||||
append_args = ["--linux-style"];
|
||||
};
|
||||
clang-format.command = getExe' pkgs.clang-tools "clang-format";
|
||||
};
|
||||
in {
|
||||
options.vim.languages.clang = {
|
||||
enable = mkEnableOption "C/C++ language support";
|
||||
|
|
@ -102,6 +153,21 @@ in {
|
|||
default = debuggers.${cfg.dap.debugger}.package;
|
||||
};
|
||||
};
|
||||
|
||||
format = {
|
||||
enable =
|
||||
mkEnableOption "C formatting"
|
||||
// {
|
||||
default = config.vim.languages.enableFormat;
|
||||
defaultText = literalExpression "config.vim.languages.enableFormat";
|
||||
};
|
||||
|
||||
type = mkOption {
|
||||
type = listOf (enum (attrNames formats));
|
||||
default = defaultFormat;
|
||||
description = "C formatter to use";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
|
|
@ -127,5 +193,23 @@ in {
|
|||
vim.debugger.nvim-dap.enable = true;
|
||||
vim.debugger.nvim-dap.sources.clang-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
|
||||
})
|
||||
|
||||
(mkIf cfg.format.enable {
|
||||
vim.formatter.conform-nvim = {
|
||||
enable = true;
|
||||
setupOpts = {
|
||||
formatters_by_ft = {
|
||||
c = cfg.format.type;
|
||||
cpp = cfg.format.type;
|
||||
};
|
||||
formatters =
|
||||
mapListToAttrs (name: {
|
||||
inherit name;
|
||||
value = formats.${name};
|
||||
})
|
||||
cfg.format.type;
|
||||
};
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,70 +7,72 @@ in {
|
|||
./asm.nix
|
||||
./astro.nix
|
||||
./bash.nix
|
||||
./env.nix
|
||||
./cue.nix
|
||||
./dart.nix
|
||||
./clang.nix
|
||||
./clojure.nix
|
||||
./cmake.nix
|
||||
./csharp.nix
|
||||
./css.nix
|
||||
./standard-ml.nix
|
||||
./scss.nix
|
||||
./cue.nix
|
||||
./dart.nix
|
||||
./docker.nix
|
||||
./elixir.nix
|
||||
./elm.nix
|
||||
./env.nix
|
||||
./fish.nix
|
||||
./fluent.nix
|
||||
./fsharp.nix
|
||||
./gettext.nix
|
||||
./gleam.nix
|
||||
./glsl.nix
|
||||
./go.nix
|
||||
./haskell.nix
|
||||
./hcl.nix
|
||||
./helm.nix
|
||||
./kotlin.nix
|
||||
./html.nix
|
||||
./tera.nix
|
||||
./twig.nix
|
||||
./liquid.nix
|
||||
./haskell.nix
|
||||
./java.nix
|
||||
./jinja.nix
|
||||
./jq.nix
|
||||
./json.nix
|
||||
./julia.nix
|
||||
./just.nix
|
||||
./kotlin.nix
|
||||
./liquid.nix
|
||||
./lua.nix
|
||||
./make.nix
|
||||
./markdown.nix
|
||||
./tex.nix
|
||||
./nim.nix
|
||||
./vala.nix
|
||||
./nix.nix
|
||||
./nu.nix
|
||||
./ocaml.nix
|
||||
./odin.nix
|
||||
./openscad.nix
|
||||
./php.nix
|
||||
./python.nix
|
||||
./qml.nix
|
||||
./r.nix
|
||||
./ruby.nix
|
||||
./rust.nix
|
||||
./scala.nix
|
||||
./scss.nix
|
||||
./scss.nix
|
||||
./sql.nix
|
||||
./standard-ml.nix
|
||||
./svelte.nix
|
||||
./vhdl.nix
|
||||
./vue.nix
|
||||
./tera.nix
|
||||
./terraform.nix
|
||||
./tex.nix
|
||||
./toml.nix
|
||||
./tsx.nix
|
||||
./twig.nix
|
||||
./typescript.nix
|
||||
./typst.nix
|
||||
./zig.nix
|
||||
./csharp.nix
|
||||
./julia.nix
|
||||
./nu.nix
|
||||
./odin.nix
|
||||
./vala.nix
|
||||
./vhdl.nix
|
||||
./vue.nix
|
||||
./wgsl.nix
|
||||
./yaml.nix
|
||||
./ruby.nix
|
||||
./just.nix
|
||||
./make.nix
|
||||
./xml.nix
|
||||
./gettext.nix
|
||||
./fluent.nix
|
||||
./openscad.nix
|
||||
./jq.nix
|
||||
./docker.nix
|
||||
./yaml.nix
|
||||
./zig.nix
|
||||
|
||||
# This is now a hard deprecation.
|
||||
(mkRenamedOptionModule ["vim" "languages" "enableLSP"] ["vim" "lsp" "enable"])
|
||||
|
|
|
|||
159
modules/plugins/languages/tsx.nix
Normal file
159
modules/plugins/languages/tsx.nix
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.options) mkEnableOption mkOption literalExpression;
|
||||
inherit (lib.types) enum listOf;
|
||||
inherit (lib.attrsets) attrNames genAttrs;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
inherit (lib.nvim.types) mkGrammarOption diagnostics;
|
||||
|
||||
cfg = config.vim.languages.tsx;
|
||||
|
||||
defaultServers = ["typescript-language-server"];
|
||||
servers = ["typescript-language-server" "deno" "typescript-go" "emmet-ls"];
|
||||
|
||||
defaultFormat = ["prettier"];
|
||||
formats = {
|
||||
prettier = {
|
||||
command = getExe pkgs.prettier;
|
||||
};
|
||||
|
||||
prettierd = {
|
||||
command = getExe pkgs.prettierd;
|
||||
};
|
||||
|
||||
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.tsx = {
|
||||
enable = mkEnableOption "Typescript XML (TSX) language support";
|
||||
|
||||
treesitter = {
|
||||
enable =
|
||||
mkEnableOption "Typescript XML (TSX) treesitter"
|
||||
// {
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
defaultText = literalExpression "config.vim.languages.enableTreesitter";
|
||||
};
|
||||
package = mkGrammarOption pkgs "tsx";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable =
|
||||
mkEnableOption "Typescript XML (TSX) LSP support"
|
||||
// {
|
||||
default = config.vim.lsp.enable;
|
||||
defaultText = literalExpression "config.vim.lsp.enable";
|
||||
};
|
||||
servers = mkOption {
|
||||
type = listOf (enum servers);
|
||||
default = defaultServers;
|
||||
description = "Typescript XML (TSX) LSP server to use";
|
||||
};
|
||||
};
|
||||
|
||||
format = {
|
||||
enable =
|
||||
mkEnableOption "Typescript XML (TSX) formatting"
|
||||
// {
|
||||
default = config.vim.languages.enableFormat;
|
||||
defaultText = literalExpression "config.vim.languages.enableFormat";
|
||||
};
|
||||
|
||||
type = mkOption {
|
||||
description = "Typescript XML (TSX) formatter to use";
|
||||
type = listOf (enum (attrNames formats));
|
||||
default = defaultFormat;
|
||||
};
|
||||
};
|
||||
|
||||
extraDiagnostics = {
|
||||
enable = mkEnableOption "extra Typescript XML (TSX) diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
|
||||
|
||||
types = diagnostics {
|
||||
langDesc = "Typescript XML (TSX)";
|
||||
inherit diagnosticsProviders;
|
||||
inherit defaultDiagnosticsProvider;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter = {
|
||||
enable = true;
|
||||
grammars = [cfg.treesitter.package];
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp = {
|
||||
presets = genAttrs cfg.lsp.servers (_: {enable = true;});
|
||||
servers = genAttrs cfg.lsp.servers (_: {
|
||||
filetypes = [
|
||||
"typescriptreact"
|
||||
"javascriptreact"
|
||||
];
|
||||
});
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.format.enable {
|
||||
vim.formatter.conform-nvim = {
|
||||
enable = true;
|
||||
setupOpts = {
|
||||
formatters_by_ft = {
|
||||
typescriptreact = cfg.format.type;
|
||||
javascriptreact = 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 = {
|
||||
typescriptreact = cfg.extraDiagnostics.types;
|
||||
javascriptreact = cfg.extraDiagnostics.types;
|
||||
};
|
||||
linters =
|
||||
mkMerge (map (name: {${name} = diagnosticsProviders.${name}.config;})
|
||||
cfg.extraDiagnostics.types);
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
@ -85,7 +85,6 @@ in {
|
|||
defaultText = literalExpression "config.vim.languages.enableTreesitter";
|
||||
};
|
||||
tsPackage = mkGrammarOption pkgs "typescript";
|
||||
tsxPackage = mkGrammarOption pkgs "tsx";
|
||||
jsPackage = mkGrammarOption pkgs "javascript";
|
||||
};
|
||||
|
||||
|
|
@ -162,7 +161,6 @@ in {
|
|||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [
|
||||
cfg.treesitter.tsPackage
|
||||
cfg.treesitter.tsxPackage
|
||||
cfg.treesitter.jsPackage
|
||||
];
|
||||
})
|
||||
|
|
@ -173,11 +171,6 @@ in {
|
|||
servers = genAttrs cfg.lsp.servers (_: {
|
||||
filetypes = [
|
||||
"typescript"
|
||||
# TODO: move to a React module
|
||||
"typescriptreact"
|
||||
"typescript.tsx"
|
||||
"javascriptreact"
|
||||
"javascript.jsx"
|
||||
# TODO: move to a JavaScript module
|
||||
"javascript"
|
||||
];
|
||||
|
|
@ -192,8 +185,6 @@ in {
|
|||
formatters_by_ft = {
|
||||
typescript = cfg.format.type;
|
||||
javascript = cfg.format.type;
|
||||
# .tsx/.jsx files
|
||||
typescriptreact = cfg.format.type;
|
||||
};
|
||||
formatters =
|
||||
mapListToAttrs (name: {
|
||||
|
|
@ -209,8 +200,6 @@ in {
|
|||
vim.diagnostics.nvim-lint = {
|
||||
enable = true;
|
||||
linters_by_ft.typescript = cfg.extraDiagnostics.types;
|
||||
linters_by_ft.typescriptreact = cfg.extraDiagnostics.types;
|
||||
|
||||
linters =
|
||||
mkMerge (map (name: {${name} = diagnosticsProviders.${name}.config;})
|
||||
cfg.extraDiagnostics.types);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue