mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-05 18:01:32 +00:00
feat: refactor and separate LSP/language configurations
This commit is contained in:
parent
7a71f06763
commit
6b512f132a
30 changed files with 1266 additions and 522 deletions
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
|
@ -6,59 +7,49 @@
|
|||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.treesitter;
|
||||
usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp";
|
||||
in {
|
||||
config = mkIf cfg.enable (
|
||||
let
|
||||
writeIf = cond: msg:
|
||||
if cond
|
||||
then msg
|
||||
else "";
|
||||
in {
|
||||
vim.startPlugins = [
|
||||
"nvim-treesitter"
|
||||
(
|
||||
if cfg.autotagHtml
|
||||
then "nvim-ts-autotag"
|
||||
else null
|
||||
)
|
||||
];
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins =
|
||||
["nvim-treesitter"]
|
||||
++ optional cfg.autotagHtml "nvim-ts-autotag"
|
||||
++ optional usingNvimCmp "cmp-treesitter";
|
||||
|
||||
# For some reason treesitter highlighting does not work on start if this is set before syntax on
|
||||
vim.configRC.treesitter = writeIf cfg.fold (nvim.dag.entryBefore ["basic"] ''
|
||||
" Tree-sitter based folding
|
||||
set foldmethod=expr
|
||||
set foldexpr=nvim_treesitter#foldexpr()
|
||||
set nofoldenable
|
||||
'');
|
||||
vim.autocomplete.sources = ["treesitter"];
|
||||
|
||||
vim.luaConfigRC.treesitter = nvim.dag.entryAnywhere ''
|
||||
-- Treesitter config
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
highlight = {
|
||||
enable = true,
|
||||
disable = {},
|
||||
# For some reason treesitter highlighting does not work on start if this is set before syntax on
|
||||
vim.configRC.treesitter-fold = mkIf cfg.fold (nvim.dag.entryBefore ["basic"] ''
|
||||
set foldmethod=expr
|
||||
set foldexpr=nvim_treesitter#foldexpr()
|
||||
set nofoldenable
|
||||
'');
|
||||
|
||||
vim.luaConfigRC.treesitter = nvim.dag.entryAnywhere ''
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
highlight = {
|
||||
enable = true,
|
||||
disable = {},
|
||||
},
|
||||
|
||||
auto_install = false,
|
||||
ensure_installed = {},
|
||||
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "gnn",
|
||||
node_incremental = "grn",
|
||||
scope_incremental = "grc",
|
||||
node_decremental = "grm",
|
||||
},
|
||||
},
|
||||
|
||||
auto_install = false,
|
||||
ensure_installed = {},
|
||||
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "gnn",
|
||||
node_incremental = "grn",
|
||||
scope_incremental = "grc",
|
||||
node_decremental = "grm",
|
||||
},
|
||||
},
|
||||
|
||||
${writeIf cfg.autotagHtml ''
|
||||
autotag = {
|
||||
enable = true,
|
||||
},
|
||||
''}
|
||||
}
|
||||
'';
|
||||
}
|
||||
);
|
||||
${optionalString cfg.autotagHtml ''
|
||||
autotag = {
|
||||
enable = true,
|
||||
},
|
||||
''}
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,51 +5,23 @@
|
|||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
with builtins; let
|
||||
cfg = config.vim.treesitter;
|
||||
usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp";
|
||||
in {
|
||||
options.vim.treesitter = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = "Enable tree-sitter [nvim-treesitter]";
|
||||
};
|
||||
enable = mkEnableOption "treesitter, also enabled automatically through language options";
|
||||
|
||||
fold = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = "Enable fold with tree-sitter";
|
||||
};
|
||||
fold = mkEnableOption "fold with treesitter";
|
||||
|
||||
autotagHtml = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = "Enable autoclose and rename html tag [nvim-ts-autotag]";
|
||||
};
|
||||
autotagHtml = mkEnableOption "autoclose and rename html tag";
|
||||
|
||||
grammars = mkOption {
|
||||
type = with types; listOf package;
|
||||
default = with (pkgs.vimPlugins.nvim-treesitter.builtGrammars);
|
||||
[
|
||||
c
|
||||
cpp
|
||||
nix
|
||||
python
|
||||
rust
|
||||
markdown
|
||||
comment
|
||||
toml
|
||||
make
|
||||
tsx
|
||||
html
|
||||
javascript
|
||||
css
|
||||
graphql
|
||||
json
|
||||
zig
|
||||
]
|
||||
++ (optional config.vim.notes.orgmode.enable org); # add orgmode grammar if enabled
|
||||
default = [];
|
||||
description = ''
|
||||
List of treesitter grammars to install.
|
||||
When enabling a language, its treesitter grammar is added for you.
|
||||
List of treesitter grammars to install. For supported languages
|
||||
use the `vim.language.<lang>.treesitter` option
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue