neovim: split plugin configs into their own file
This commit is contained in:
@@ -1,87 +1,10 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
moduleArgs@{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (builtins) map;
|
inherit (builtins) map;
|
||||||
inherit (lib) concatMapStrings mkIf optionalString;
|
inherit (lib) concatMapStrings mkIf optionalString;
|
||||||
# this structure roughly mirrors home-manager's `programs.neovim.plugins` option
|
# this structure roughly mirrors home-manager's `programs.neovim.plugins` option
|
||||||
plugins = with pkgs.vimPlugins; [
|
plugins = import ./plugins.nix moduleArgs;
|
||||||
{
|
|
||||||
# docs: fzf-vim (fuzzy finder): https://github.com/junegunn/fzf.vim
|
|
||||||
plugin = fzf-vim;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
# treesitter syntax highlighting: https://nixos.wiki/wiki/Tree_sitters
|
|
||||||
# docs: https://github.com/nvim-treesitter/nvim-treesitter
|
|
||||||
# config taken from: https://github.com/i077/system/blob/master/modules/home/neovim/default.nix
|
|
||||||
# this is required for tree-sitter to even highlight
|
|
||||||
# XXX(2024/06/03): `unison` removed because it doesn't cross compile
|
|
||||||
plugin = nvim-treesitter.withPlugins (_: (lib.filter (p: p.pname != "unison-grammar") nvim-treesitter.allGrammars) ++ [
|
|
||||||
# XXX: this is apparently not enough to enable syntax highlighting!
|
|
||||||
# nvim-treesitter ships its own queries which may be distinct from e.g. helix.
|
|
||||||
# the queries aren't included when i ship the grammar in this manner
|
|
||||||
pkgs.tree-sitter-nix-shell
|
|
||||||
]);
|
|
||||||
type = "lua";
|
|
||||||
config = ''
|
|
||||||
-- lifted mostly from readme: <https://github.com/nvim-treesitter/nvim-treesitter>
|
|
||||||
require'nvim-treesitter.configs'.setup {
|
|
||||||
highlight = {
|
|
||||||
enable = true,
|
|
||||||
-- disable treesitter on Rust so that we can use SyntaxRange
|
|
||||||
-- and leverage TeX rendering in rust projects
|
|
||||||
disable = { "rust", "tex", "latex" },
|
|
||||||
-- disable = { "tex", "latex" },
|
|
||||||
-- true to also use builtin vim syntax highlighting when treesitter fails
|
|
||||||
additional_vim_regex_highlighting = false
|
|
||||||
},
|
|
||||||
incremental_selection = {
|
|
||||||
enable = true,
|
|
||||||
keymaps = {
|
|
||||||
init_selection = "gnn",
|
|
||||||
node_incremental = "grn",
|
|
||||||
scope_incremental = "grc",
|
|
||||||
node_decremental = "grm"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
indent = {
|
|
||||||
enable = true,
|
|
||||||
disable = {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vim.o.foldmethod = 'expr'
|
|
||||||
vim.o.foldexpr = 'nvim_treesitter#foldexpr()'
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
{
|
|
||||||
# docs: tex-conceal-vim: https://github.com/KeitaNakamura/tex-conceal.vim/
|
|
||||||
plugin = tex-conceal-vim;
|
|
||||||
type = "viml";
|
|
||||||
config = ''
|
|
||||||
" present prettier fractions
|
|
||||||
let g:tex_conceal_frac=1
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
{
|
|
||||||
# source: <https://github.com/LnL7/vim-nix>
|
|
||||||
# fixes auto-indent (incl tab size) when editing .nix files
|
|
||||||
plugin = vim-nix;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
# docs: surround-nvim: https://github.com/ur4ltz/surround.nvim/
|
|
||||||
# docs: vim-surround: https://github.com/tpope/vim-surround
|
|
||||||
plugin = vim-surround;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = vim-SyntaxRange;
|
|
||||||
type = "viml";
|
|
||||||
config = ''
|
|
||||||
" enable markdown-style codeblock highlighting for tex code
|
|
||||||
autocmd BufEnter * call SyntaxRange#Include('```tex', '```', 'tex', 'NonText')
|
|
||||||
" autocmd Syntax tex set conceallevel=2
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
];
|
|
||||||
plugin-packages = map (p: p.plugin) plugins;
|
plugin-packages = map (p: p.plugin) plugins;
|
||||||
plugin-config-viml = concatMapStrings (p: optionalString (p.type or "" == "viml") p.config) plugins;
|
plugin-config-viml = concatMapStrings (p: optionalString (p.type or "" == "viml") p.config) plugins;
|
||||||
plugin-config-lua = concatMapStrings (p: optionalString (p.type or "" == "lua") p.config) plugins;
|
plugin-config-lua = concatMapStrings (p: optionalString (p.type or "" == "lua") p.config) plugins;
|
||||||
|
79
hosts/common/programs/neovim/plugins.nix
Normal file
79
hosts/common/programs/neovim/plugins.nix
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
with pkgs.vimPlugins;
|
||||||
|
[
|
||||||
|
{
|
||||||
|
# docs: fzf-vim (fuzzy finder): https://github.com/junegunn/fzf.vim
|
||||||
|
plugin = fzf-vim;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
# treesitter syntax highlighting: https://nixos.wiki/wiki/Tree_sitters
|
||||||
|
# docs: https://github.com/nvim-treesitter/nvim-treesitter
|
||||||
|
# config taken from: https://github.com/i077/system/blob/master/modules/home/neovim/default.nix
|
||||||
|
# this is required for tree-sitter to even highlight
|
||||||
|
plugin = nvim-treesitter.withPlugins (_: nvim-treesitter.allGrammars ++ [
|
||||||
|
# XXX: this is apparently not enough to enable syntax highlighting!
|
||||||
|
# nvim-treesitter ships its own queries which may be distinct from e.g. helix.
|
||||||
|
# the queries aren't included when i ship the grammar in this manner
|
||||||
|
pkgs.tree-sitter-nix-shell
|
||||||
|
]);
|
||||||
|
type = "lua";
|
||||||
|
config = ''
|
||||||
|
-- lifted mostly from readme: <https://github.com/nvim-treesitter/nvim-treesitter>
|
||||||
|
require'nvim-treesitter.configs'.setup {
|
||||||
|
highlight = {
|
||||||
|
enable = true,
|
||||||
|
-- disable treesitter on Rust so that we can use SyntaxRange
|
||||||
|
-- and leverage TeX rendering in rust projects
|
||||||
|
disable = { "rust", "tex", "latex" },
|
||||||
|
-- disable = { "tex", "latex" },
|
||||||
|
-- true to also use builtin vim syntax highlighting when treesitter fails
|
||||||
|
additional_vim_regex_highlighting = false
|
||||||
|
},
|
||||||
|
incremental_selection = {
|
||||||
|
enable = true,
|
||||||
|
keymaps = {
|
||||||
|
init_selection = "gnn",
|
||||||
|
node_incremental = "grn",
|
||||||
|
scope_incremental = "grc",
|
||||||
|
node_decremental = "grm"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
indent = {
|
||||||
|
enable = true,
|
||||||
|
disable = {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.o.foldmethod = 'expr'
|
||||||
|
vim.o.foldexpr = 'nvim_treesitter#foldexpr()'
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
{
|
||||||
|
# docs: tex-conceal-vim: https://github.com/KeitaNakamura/tex-conceal.vim/
|
||||||
|
plugin = tex-conceal-vim;
|
||||||
|
type = "viml";
|
||||||
|
config = ''
|
||||||
|
" present prettier fractions
|
||||||
|
let g:tex_conceal_frac=1
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
{
|
||||||
|
# source: <https://github.com/LnL7/vim-nix>
|
||||||
|
# fixes auto-indent (incl tab size) when editing .nix files
|
||||||
|
plugin = vim-nix;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
# docs: surround-nvim: https://github.com/ur4ltz/surround.nvim/
|
||||||
|
# docs: vim-surround: https://github.com/tpope/vim-surround
|
||||||
|
plugin = vim-surround;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
plugin = vim-SyntaxRange;
|
||||||
|
type = "viml";
|
||||||
|
config = ''
|
||||||
|
" enable markdown-style codeblock highlighting for tex code
|
||||||
|
autocmd BufEnter * call SyntaxRange#Include('```tex', '```', 'tex', 'NonText')
|
||||||
|
" autocmd Syntax tex set conceallevel=2
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
]
|
Reference in New Issue
Block a user