feat: refactor and separate LSP/language configurations

This commit is contained in:
NotAShelf 2023-04-17 23:27:27 +03:00
commit 6b512f132a
No known key found for this signature in database
GPG key ID: F0D14CCB5ED5AA22
30 changed files with 1266 additions and 522 deletions

View file

@ -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,
},
''}
}
'';
};
}