mirror of
https://github.com/jbowdre/dotfiles.git
synced 2024-12-18 10:52:18 +00:00
neovim configs
This commit is contained in:
parent
54f6a84162
commit
0fa0948450
15 changed files with 461 additions and 0 deletions
25
home/modules/tui/neovim/autocmds.nix
Normal file
25
home/modules/tui/neovim/autocmds.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
programs.nixvim.autoCmd = [
|
||||
# Vertically center document when entering insert mode
|
||||
{
|
||||
event = "InsertEnter";
|
||||
command = "norm zz";
|
||||
}
|
||||
|
||||
# Open help in a vertical split
|
||||
{
|
||||
event = "FileType";
|
||||
pattern = "help";
|
||||
command = "wincmd L";
|
||||
}
|
||||
|
||||
# Enable spellcheck for some filetypes
|
||||
{
|
||||
event = "FileType";
|
||||
pattern = [
|
||||
"markdown"
|
||||
];
|
||||
command = "setlocal spell spelllang=en";
|
||||
}
|
||||
];
|
||||
}
|
55
home/modules/tui/neovim/completion.nix
Normal file
55
home/modules/tui/neovim/completion.nix
Normal file
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
programs.nixvim = {
|
||||
opts.completeopt = ["menu" "menuone" "noselect"];
|
||||
|
||||
plugins = {
|
||||
luasnip.enable = true;
|
||||
|
||||
lspkind = {
|
||||
enable = true;
|
||||
|
||||
cmp = {
|
||||
enable = true;
|
||||
menu = {
|
||||
nvim_lsp = "[LSP]";
|
||||
nvim_lua = "[api]";
|
||||
path = "[path]";
|
||||
luasnip = "[snip]";
|
||||
buffer = "[buffer]";
|
||||
nixpkgs_maintainers = "[nixpkgs]";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
cmp = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end";
|
||||
|
||||
mapping = {
|
||||
"<C-d>" = "cmp.mapping.scroll_docs(-4)";
|
||||
"<C-f>" = "cmp.mapping.scroll_docs(4)";
|
||||
"<C-Space>" = "cmp.mapping.complete()";
|
||||
"<C-e>" = "cmp.mapping.close()";
|
||||
"<Tab>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
|
||||
"<S-Tab>" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})";
|
||||
"<CR>" = "cmp.mapping.confirm({ select = true })";
|
||||
};
|
||||
|
||||
sources = [
|
||||
{name = "path";}
|
||||
{name = "nvim_lsp";}
|
||||
{name = "luasnip";}
|
||||
{name = "nixpkgs_maintainers";}
|
||||
{
|
||||
name = "buffer";
|
||||
# words from other open buffers can also be suggested
|
||||
option.get_bufnrs.__raw = "vim.api.nvim_list_bufs";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -2,9 +2,27 @@
|
|||
|
||||
imports = [
|
||||
inputs.nixvim.homeManagerModules.nixvim
|
||||
./autocmds.nix
|
||||
./completion.nix
|
||||
./keymaps.nix
|
||||
./options.nix
|
||||
./plugins
|
||||
];
|
||||
|
||||
programs.nixvim = {
|
||||
enable = true;
|
||||
|
||||
performance = {
|
||||
combinePlugins = {
|
||||
enable = true;
|
||||
standalonePlugins = [
|
||||
"hmts.nvim"
|
||||
"nvim-treesitter"
|
||||
];
|
||||
};
|
||||
byteCompileLua.enable = true;
|
||||
};
|
||||
|
||||
luaLoader.enable = true;
|
||||
};
|
||||
}
|
||||
|
|
74
home/modules/tui/neovim/keymaps.nix
Normal file
74
home/modules/tui/neovim/keymaps.nix
Normal file
|
@ -0,0 +1,74 @@
|
|||
{ config, lib, ... }: {
|
||||
programs.nixvim = {
|
||||
globals = {
|
||||
mapleader = " ";
|
||||
maplocalleader = " ";
|
||||
};
|
||||
|
||||
keymaps = let
|
||||
normal =
|
||||
lib.mapAttrsToList
|
||||
(key: action: {
|
||||
mode = "n";
|
||||
inherit action key;
|
||||
})
|
||||
{
|
||||
"<Space>" = "<NOP>";
|
||||
|
||||
# Esc to clear search results
|
||||
"<esc>" = ":noh<CR>";
|
||||
|
||||
# fix Y behavior
|
||||
Y = "y$";
|
||||
|
||||
# toggle between two most recent files
|
||||
"<C-c>" = ":b#<CR>";
|
||||
|
||||
# close by Ctrl+x
|
||||
"<C-x>" = ":close<CR>";
|
||||
|
||||
# save by Space+s or Ctrl+s
|
||||
"<leader>s" = ":w<CR>";
|
||||
"<C-s>" = ":w<CR>";
|
||||
|
||||
# H, L to jump to start/end of line
|
||||
L = "$";
|
||||
H = "^";
|
||||
|
||||
# resize with arrows
|
||||
"<C-Up>" = ":resize -2<CR>";
|
||||
"<C-Down>" = ":resize +2<CR>";
|
||||
"<C-Left>" = ":vertical resize +2<CR>";
|
||||
"<C-Right>" = ":vertical resize -2<CR>";
|
||||
|
||||
# move current line up/down
|
||||
# M = Alt
|
||||
"<M-k>" = ":move-2<CR>";
|
||||
"<M-j>" = ":move+<CR>";
|
||||
};
|
||||
visual =
|
||||
lib.mapAttrsToList
|
||||
(key: action: {
|
||||
mode = "v";
|
||||
inherit action key;
|
||||
})
|
||||
{
|
||||
# better indenting
|
||||
">" = ">gv";
|
||||
"<" = "<gv";
|
||||
"<TAB>" = ">gv";
|
||||
"<S-TAB>" = "<gv";
|
||||
|
||||
# move selected line/block in visual mode
|
||||
"K" = ":m '<-2<CR>gv=gv";
|
||||
"J" = ":m '>+1<CR>gv=gv";
|
||||
|
||||
# sort
|
||||
"<leader>s" = ":sort<CR>";
|
||||
};
|
||||
in
|
||||
config.lib.nixvim.keymaps.mkKeymaps
|
||||
{options.silent = true;}
|
||||
(normal ++ visual);
|
||||
};
|
||||
}
|
46
home/modules/tui/neovim/options.nix
Normal file
46
home/modules/tui/neovim/options.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
programs.nixvim = {
|
||||
clipboard = {
|
||||
providers = {
|
||||
wl-copy.enable = true;
|
||||
xsel.enable = true;
|
||||
};
|
||||
register = "unnamedplus";
|
||||
};
|
||||
|
||||
opts = {
|
||||
updatetime = 100; # Faster completion
|
||||
relativenumber = true; # Relative line numbers
|
||||
number = true; # Display absolute line number of current line
|
||||
hidden = true; # Keep closed buffer open in the background
|
||||
mouse = "a"; # Enable mouse control
|
||||
mousemodel = "extend"; # Mouse right-click extends the current selection
|
||||
splitbelow = true; # A new window is put below the current one
|
||||
splitright = true; # A new window is put right of the corrent one
|
||||
swapfile = false; # Disable the swap file
|
||||
modeline = true; # tags such as 'vim:ft=sh'
|
||||
modelines = 5; # check first and last five lines for modelines
|
||||
undofile = true; # save and restore undo history
|
||||
incsearch = true; # incremental search: show match for partly typed search command
|
||||
inccommand = "split"; # search and replace: preview changes in quickfix list
|
||||
ignorecase = true; # when search query is lowercase match both lower and upper patterns
|
||||
smartcase = true; # override ignorecase if search pattern containers upper case
|
||||
scrolloff = 8; # number of lines to show around the cursor
|
||||
cursorline = true; # highlight the screen line of the cursor
|
||||
cursorcolumn = false; # highlight the screen column of the cursor
|
||||
signcolumn = "yes"; # whether to show the signcolumn
|
||||
colorcolumn = "100"; # columns to highlight
|
||||
laststatus = 3; # when to use a status line for the last window
|
||||
fileencoding = "utf-8"; # file-content encoding for the current buffer
|
||||
termguicolors = true; # enables 24-bit colors
|
||||
spell = false; # highlight spelling mistakes
|
||||
wrap = false; # prevent wrapping text
|
||||
tabstop = 2; # number of spaces a <Tab> in the text stands for
|
||||
shiftwidth = 2; # number of spaces used for each step of (auto)indent
|
||||
expandtab = true; # expand <Tab> to spaces in Insert mode
|
||||
autoindent = true; # do clever autoindenting
|
||||
textwidth = 0; # maximum width of text that is being inserted, a longer line will be broken after whitespace to this width
|
||||
foldlevel = 99; # folds with a level higher than this number will be closed
|
||||
};
|
||||
};
|
||||
}
|
10
home/modules/tui/neovim/plugins/barbar.nix
Normal file
10
home/modules/tui/neovim/plugins/barbar.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
programs.nixvim.plugins.barbar = {
|
||||
enable = true;
|
||||
keymaps = {
|
||||
next.key = "<TAB>";
|
||||
previous.key = "<S-TAB>";
|
||||
close.key = "<C-w>";
|
||||
};
|
||||
};
|
||||
}
|
10
home/modules/tui/neovim/plugins/comment.nix
Normal file
10
home/modules/tui/neovim/plugins/comment.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
programs.nixvim.plugins.comment = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
opleader.line = "<C-b>";
|
||||
toggler.line = "<C-b>";
|
||||
};
|
||||
};
|
||||
}
|
52
home/modules/tui/neovim/plugins/default.nix
Normal file
52
home/modules/tui/neovim/plugins/default.nix
Normal file
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
imports = [
|
||||
./barbar.nix
|
||||
./comment.nix
|
||||
./floaterm.nix
|
||||
./harpoon.nix
|
||||
./lsp.nix
|
||||
./md-preview.nix
|
||||
./neo-tree.nix
|
||||
./telescope.nix
|
||||
./treesitter.nix
|
||||
];
|
||||
|
||||
programs.nixvim = {
|
||||
colorschemes.catppuccin.enable = true;
|
||||
|
||||
plugins = {
|
||||
web-devicons.enable = true;
|
||||
|
||||
gitsigns = {
|
||||
enable = true;
|
||||
settings.signs = {
|
||||
add.text = "+";
|
||||
change.text = "~";
|
||||
};
|
||||
};
|
||||
|
||||
nvim-autopairs.enable = true;
|
||||
|
||||
nvim-colorizer = {
|
||||
enable = true;
|
||||
userDefaultOptions.names = false;
|
||||
};
|
||||
|
||||
oil.enable = true;
|
||||
|
||||
trim = {
|
||||
enable = true;
|
||||
settings = {
|
||||
highlight = true;
|
||||
ft_blocklist = [
|
||||
"checkhealth"
|
||||
"floaterm"
|
||||
"lsipinfo"
|
||||
"neo-tree"
|
||||
"TelescopePrompt"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
12
home/modules/tui/neovim/plugins/floaterm.nix
Normal file
12
home/modules/tui/neovim/plugins/floaterm.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
programs.nixvim.plugins.floaterm = {
|
||||
enable = true;
|
||||
|
||||
width = 0.8;
|
||||
height = 0.8;
|
||||
|
||||
title = "";
|
||||
|
||||
keymaps.toggle = "<leader>,";
|
||||
};
|
||||
}
|
20
home/modules/tui/neovim/plugins/harpoon.nix
Normal file
20
home/modules/tui/neovim/plugins/harpoon.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
programs.nixvim = {
|
||||
plugins.harpoon = {
|
||||
enable = true;
|
||||
|
||||
keymapsSilent = true;
|
||||
|
||||
keymaps = {
|
||||
addFile = "<leader>a";
|
||||
toggleQuickMenu = "<C-e>";
|
||||
navFile = {
|
||||
"1" = "<C-j>";
|
||||
"2" = "<C-k>";
|
||||
"3" = "<C-l>";
|
||||
"4" = "<C-m>";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
38
home/modules/tui/neovim/plugins/lsp.nix
Normal file
38
home/modules/tui/neovim/plugins/lsp.nix
Normal file
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
programs.nixvim = {
|
||||
plugins = {
|
||||
lsp-format = {
|
||||
enable = true;
|
||||
lspServersToEnable = "all";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = true;
|
||||
|
||||
inlayHints = true;
|
||||
|
||||
keymaps = {
|
||||
silent = true;
|
||||
diagnostic = {
|
||||
# navigate in diagnostics
|
||||
"<leader>k" = "goto_prev";
|
||||
"<leader>j" = "goto_next";
|
||||
};
|
||||
|
||||
lspBuf = {
|
||||
gd = "definition";
|
||||
gD = "references";
|
||||
gt = "type_definition";
|
||||
gi = "implementation";
|
||||
K = "hover";
|
||||
"<F2>" = "rename";
|
||||
};
|
||||
};
|
||||
|
||||
servers = {
|
||||
clangd.enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
20
home/modules/tui/neovim/plugins/md-preview.nix
Normal file
20
home/modules/tui/neovim/plugins/md-preview.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
programs.nixvim = {
|
||||
plugins.markdown-preview = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
auto_close = 0;
|
||||
theme = "dark";
|
||||
};
|
||||
};
|
||||
|
||||
files."after/ftplugin/markdown.lua".keymaps = [
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>m";
|
||||
action = ":MarkdownPreview<cr>";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
22
home/modules/tui/neovim/plugins/neo-tree.nix
Normal file
22
home/modules/tui/neovim/plugins/neo-tree.nix
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
programs.nixvim = {
|
||||
keymaps = [
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>n";
|
||||
action = ":Neotree action=focus reveal toggle<CR>";
|
||||
options.silent = true;
|
||||
}
|
||||
];
|
||||
|
||||
plugins.neo-tree = {
|
||||
enable = true;
|
||||
|
||||
closeIfLastWindow = true;
|
||||
window = {
|
||||
width = 30;
|
||||
autoExpandWidth = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
33
home/modules/tui/neovim/plugins/telescope.nix
Normal file
33
home/modules/tui/neovim/plugins/telescope.nix
Normal file
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
programs.nixvim = {
|
||||
plugins.telescope = {
|
||||
enable = true;
|
||||
|
||||
keymaps = {
|
||||
# find files using telescope command-line sugar
|
||||
"<leader>ff" = "find_files";
|
||||
"<leader>fg" = "live_grep";
|
||||
"<leader>b" = "buffers";
|
||||
"<leader>fh" = "help_tags";
|
||||
"<leader>fd" = "diagnostics";
|
||||
|
||||
# fzf like bindings
|
||||
"<C-p>" = "git_files";
|
||||
"<leader>p" = "oldfiles";
|
||||
"<C-f>" = "live_grep";
|
||||
};
|
||||
|
||||
settings.defaults = {
|
||||
file_ignore_patterns = [
|
||||
"^.git/"
|
||||
"^.mypy_cache/"
|
||||
"^__pycache__/"
|
||||
"^output/"
|
||||
"^data/"
|
||||
"%.ipynb"
|
||||
];
|
||||
set_env.COLORTERM = "truecolor";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
26
home/modules/tui/neovim/plugins/treesitter.nix
Normal file
26
home/modules/tui/neovim/plugins/treesitter.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
programs.nixvim.plugins = {
|
||||
treesitter = {
|
||||
enable = true;
|
||||
|
||||
nixvimInjections = true;
|
||||
|
||||
settings = {
|
||||
highlight.enable = true;
|
||||
indent.enable = true;
|
||||
};
|
||||
folding = true;
|
||||
};
|
||||
|
||||
treesitter-refactor = {
|
||||
enable = true;
|
||||
highlightDefinitions = {
|
||||
enable = true;
|
||||
# set to false if you have an updatetime of ~100
|
||||
clearOnCursorMove = false;
|
||||
};
|
||||
};
|
||||
|
||||
hmts.enable = true;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue