dotfiles/modules/common/neovim/config/misc.nix

80 lines
2.9 KiB
Nix
Raw Permalink Normal View History

2022-11-28 02:11:41 +00:00
{ pkgs, dsl, lib, ... }: {
2022-11-27 20:08:33 +00:00
plugins = [
2022-11-28 02:11:41 +00:00
pkgs.vimPlugins.vim-surround # Keybinds for surround characters
pkgs.vimPlugins.vim-eunuch # File manipulation commands
pkgs.vimPlugins.vim-fugitive # Git commands
pkgs.vimPlugins.vim-repeat # Better repeat using .
pkgs.vimPlugins.comment-nvim # Smart comment commands
2022-11-29 05:11:57 +00:00
pkgs.vimPlugins.glow-nvim # Markdown preview popup
pkgs.vimPlugins.nvim-colorizer-lua # Hex color previews
2023-07-29 12:18:49 +00:00
pkgs.vimPlugins.which-key-nvim # Keybind helper
2022-11-27 20:08:33 +00:00
];
2022-11-28 02:11:41 +00:00
2023-07-31 00:26:23 +00:00
# Initialize some plugins
2022-11-27 20:08:33 +00:00
setup.Comment = { };
2022-11-29 05:11:57 +00:00
setup.colorizer = { };
2023-07-09 20:51:23 +00:00
setup.glow = { };
2023-07-29 12:18:49 +00:00
setup.which-key = { };
2022-11-28 00:21:18 +00:00
2022-11-29 16:35:39 +00:00
vim.o = {
termguicolors = true; # Set to truecolor
hidden = true; # Don't unload buffers when leaving them
list = true; # Reveal whitespace with dashes
expandtab = true; # Tabs into spaces
shiftwidth = 4; # Amount to shift with > key
softtabstop = 4; # Amount to shift with <TAB> key
ignorecase = true; # Ignore case when searching
smartcase = true; # Check case when using capitals in search
infercase = true; # Don't match cases when completing suggestions
incsearch = true; # Search while typing
visualbell = true; # No sounds
scrolljump = 1; # Number of lines to scroll
scrolloff = 3; # Margin of lines to see while scrolling
splitright = true; # Vertical splits on the right side
splitbelow = true; # Horizontal splits on the bottom side
pastetoggle = "<F3>"; # Use F3 to enter raw paste mode
clipboard = "unnamedplus"; # Uses system clipboard for yanking
updatetime = 300; # Faster diagnostics
mouse = "nv"; # Mouse interaction / scrolling
inccommand = "split"; # Live preview search and replace
};
vim.wo = {
number = true; # Show line numbers
relativenumber = true; # Relative numbers instead of absolute
};
2022-11-28 00:21:18 +00:00
2023-07-29 12:18:49 +00:00
# For which-key-nvim
vim.o.timeout = true;
vim.o.timeoutlen = 300;
2022-11-28 02:11:41 +00:00
# Better backup, swap and undo storage
vim.o.backup = true; # Easier to recover and more secure
vim.bo.swapfile = false; # Instead of swaps, create backups
vim.bo.undofile = true; # Keeps undos after quit
vim.o.backupdir =
dsl.rawLua ''vim.fn.expand("~/.local/state/nvim/backup//")'';
vim.o.undodir = dsl.rawLua ''vim.fn.expand("~/.local/state/nvim/undo//")'';
2022-11-28 02:11:41 +00:00
2022-11-28 00:21:18 +00:00
# Required for nvim-cmp completion
vim.opt.completeopt = [ "menu" "menuone" "noselect" ];
lua = lib.mkBefore ''
vim.loader.enable()
2022-11-27 20:08:33 +00:00
${builtins.readFile ../lua/keybinds.lua};
${builtins.readFile ../lua/settings.lua};
'';
2022-11-28 02:11:41 +00:00
vimscript = ''
" Remember last position when reopening file
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
" LaTeX options
au FileType tex inoremap ;bf \textbf{}<Esc>i
au BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw!
" Flash highlight when yanking
au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 }
'';
2022-11-27 20:08:33 +00:00
}