nix-config/modules/neovim/_editing.nix

93 lines
2.4 KiB
Nix

{ pkgs, ... }:
{
programs.nixvim = {
plugins.guess-indent.enable = true;
plugins.nvim-surround.enable = true;
plugins.flash.enable = true;
plugins.nvim-autopairs.enable = true;
# Workaround: Neovim 0.11.x does not implement the is? / is-not? treesitter
# predicates, but newer grammar query files (tree-sitter-nix, tree-sitter-javascript)
# use (#is-not? local) to scope highlights to non-local identifiers.
# Register no-op handlers to suppress the error; remove once Neovim
# ships with built-in support for these predicates.
extraConfigLua = /* lua */ ''
-- (#is?) always returns false (node never "is" something)
vim.treesitter.query.add_predicate("is?", function()
return false
end, { force = true })
-- (#is-not?) always returns true (node is always "not" something)
vim.treesitter.query.add_predicate("is-not?", function()
return true
end, { force = true })
'';
plugins.treesitter = {
enable = true;
highlight.enable = true;
indent.enable = false;
folding.enable = true;
grammarPackages = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [
angular
bash
css
html
javascript
jsdoc
json
lua
make
markdown
markdown_inline
go
gomod
gotmpl
python
styled
tsx
typescript
nix
regex
toml
vim
vimdoc
xml
yaml
];
};
plugins.substitute = {
enable = true;
luaConfig.post = /* lua */ ''
local sub = require("substitute")
vim.keymap.set("n", "s", sub.operator, { noremap = true })
vim.keymap.set("n", "ss", sub.line, { noremap = true })
vim.keymap.set("n", "S", sub.eol, { noremap = true })
vim.keymap.set("x", "s", sub.visual, { noremap = true })
'';
};
extraPlugins = [
pkgs.vimPlugins.vim-cool
];
autoCmd = [
{
callback.__raw = "function() vim.highlight.on_yank() end";
event = [
"TextYankPost"
];
}
{
event = [ "FileType" ];
pattern = "qf";
callback.__raw = /* lua */ ''
function()
vim.keymap.set("n", "<CR>", "<CR>", { buffer = true })
end
'';
}
];
};
}