Skip to content

Commit

Permalink
feat: autopairs, cursor restore and rename option (#15)
Browse files Browse the repository at this point in the history
Add the nvim-autopairs so "'{[ characters will auto close.
Add AutoCmd to restore the cursor position when re-opening file.
Fix treesitter option name.
  • Loading branch information
dc-tec authored Jul 25, 2024
1 parent 21072b3 commit 48bbb79
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 39 deletions.
21 changes: 21 additions & 0 deletions config/auto_cmds.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
highlight_yank = {};
vim_enter = {};
indentscope = {};
restore_cursor = {};
};

autoCmd = [
Expand Down Expand Up @@ -50,5 +51,25 @@
'';
};
}
## from NVChad https://nvchad.com/docs/recipes (this autocmd will restore the cursor position when opening a file)
{
group = "restore_cursor";
event = ["BufReadPost"];
pattern = "*";
callback = {
__raw = ''
function()
if
vim.fn.line "'\"" > 1
and vim.fn.line "'\"" <= vim.fn.line "$"
and vim.bo.filetype ~= "commit"
and vim.fn.index({ "xxd", "gitrebase" }, vim.bo.filetype) == -1
then
vim.cmd "normal! g`\""
end
end
'';
};
}
];
}
1 change: 1 addition & 0 deletions config/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ _: {
./plugins/cmp/cmp.nix
./plugins/cmp/cmp-copilot.nix
./plugins/cmp/lspkind.nix
./plugins/cmp/autopairs.nix

# Snippets
./plugins/snippets/luasnip.nix
Expand Down
8 changes: 8 additions & 0 deletions config/plugins/cmp/autopairs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
plugins.nvim-autopairs = {
enable = true;
settings = {
disable_filetype = ["TelescopePrompt" "vim"];
};
};
}
4 changes: 3 additions & 1 deletion config/plugins/editor/treesitter.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{pkgs, ...}: {
plugins.treesitter = {
enable = true;
indent = true;
settings = {
indent.enable = true;
};
folding = false;
nixvimInjections = true;
grammarPackages = pkgs.vimPlugins.nvim-treesitter.allGrammars;
Expand Down
103 changes: 65 additions & 38 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 48bbb79

Please sign in to comment.