nicks-nix-config/modules/neovim.nix

282 lines
6.1 KiB
Nix
Raw Permalink Normal View History

2024-10-09 20:04:12 -07:00
{ pkgs, lib, zls, ... }:
2023-07-29 12:48:45 -07:00
let
in
{
2023-08-05 09:30:37 -07:00
home.packages = with pkgs; [
# Required clipboard provider
xclip
2023-09-21 11:23:37 -07:00
# Required for find in file
ripgrep
2023-08-05 09:30:37 -07:00
];
2023-07-29 12:48:45 -07:00
programs.nixvim = {
enable = true;
2023-07-29 12:48:45 -07:00
viAlias = true;
vimAlias = true;
2023-07-29 16:01:53 -07:00
globals = {
mapleader = " ";
};
2024-01-11 21:13:06 -08:00
filetype.extension = {
templ = "templ";
};
2024-04-13 16:16:39 -07:00
opts = {
2023-07-29 16:01:53 -07:00
autoindent = true;
expandtab = true;
foldlevel=20;
guifont = "MesloLGS\ NF\ 10";
number = true;
shiftwidth = 4;
tabstop = 4;
};
2023-10-08 13:28:49 -07:00
keymaps = [
# Modes: https://superuser.com/questions/1702308/how-can-i-configure-shortcut-keys-in-all-modes-of-vim
# n - normal
# i - insert
# c - cmd
# v - visual select
# x - visual only
# s - selection
# o - oper
# t - terminal
# l - lang
{
# Open new vertical split and starts a new terminal window
mode = "n";
key = "<leader>ot";
action = "<cmd>vs | te<cr>";
}
{
# toggle the left tree panel
mode = "n";
key = "<leader>op";
action = "<cmd>NvimTreeToggle<cr>";
}
{
# Open cwd filename fuzzy search
mode = "n";
key = "<leader>o.";
action = "<cmd>Telescope file_browser<cr>";
}
{
# Open fuzzy filename recursive search
mode = "n";
key = "<leader>.";
action = "<cmd>Telescope find_files<cr>";
}
{
# Search file contents of cwd
mode = "n";
key = "<leader>of";
action = "<cmd>Telescope live_grep<cr>";
}
{
# Keep cursor centered while navigating
mode = "n";
key = "<C-d>";
action = "<C-d>zz";
}
{
# Keep cursor centered while navigating
mode = "n";
key = "<C-u>";
action = "<C-u>zz";
}
{
# Keep cursor centered while skipping to search results
mode = "n";
key = "n";
action = "nzzzv";
}
{
# Keep cursor centered while skipping to search results
mode = "n";
key = "N";
action = "Nzzzv";
}
{
# Yank to system clipboard
mode = "n";
key = "<leader>y";
action = "\"+y";
}
{
# Yank to system clipboard
mode = "n";
key = "<leader>Y";
action = "\"+Y";
}
{
# Delete into the void
mode = "n";
key = "<leader>d";
action = "\"_d";
}
{
# Move visual selection up one row
mode = "v";
key = "J";
action = ":m '>+1<CR>gv=gv";
}
{
# Move visual selection down one row
mode = "v";
key = "K";
action = ":m '<-2<CR>gv=gv";
}
2023-12-20 17:19:53 -08:00
{
mode = "v";
key = ">";
action = ">gv";
}
{
mode = "v";
key = "<";
action = "<gv";
}
2023-10-08 13:28:49 -07:00
{
# Yank selection to system clipboard
mode = "v";
key = "<leader>y";
action = "\"+y";
}
{
# Delete selection into void
mode = "v";
key = "<leader>d";
action = "\"_d";
}
2023-10-08 13:28:49 -07:00
{
# leader+p delete the selection to the void, then paste
mode = "x";
key = "<leader>p";
action = "\"_dP";
}
];
2023-07-29 16:01:53 -07:00
plugins = {
2024-10-06 08:36:03 -07:00
web-devicons.enable = true; # text icons
2024-08-08 18:19:57 -07:00
typescript-tools.enable = true;
2024-10-09 20:04:12 -07:00
zig = {
enable = true;
settings = {
fmt_autosave = 0;
};
};
2023-08-11 09:08:09 -07:00
2023-12-31 17:05:25 -08:00
lsp = {
enable = true;
servers = {
2024-10-09 20:04:12 -07:00
zls = {
2024-03-16 16:56:39 -07:00
enable = true;
2024-10-09 20:04:12 -07:00
package = zls.packages.${pkgs.system}.zls;
2024-03-16 16:56:39 -07:00
};
2024-10-09 20:04:12 -07:00
# gleam = {
# enable = true;
# autostart = true;
# };
2023-12-31 17:05:25 -08:00
gopls = {
enable = true;
};
2024-01-11 20:41:23 -08:00
templ = {
enable = true;
2024-01-11 21:13:06 -08:00
autostart = true;
2024-01-11 20:41:23 -08:00
};
2023-12-31 17:05:25 -08:00
html.enable = true;
2024-01-12 19:20:13 -08:00
cssls.enable = true;
2023-12-31 17:05:25 -08:00
};
};
2023-08-05 08:47:54 -07:00
nvim-tree = {
enable = true;
openOnSetup = true;
};
2023-08-05 08:47:54 -07:00
2024-06-25 20:27:26 -07:00
# ts-autotag = {
# enable = true;
# filetypes = [ "html" "javascript" "typescript" "javascriptreact" "typescriptreact" "svelte" "vue" "tsx" "jsx" "rescript" "xml" "php" "markdown" "astro" "glimmer" "handlebars" "hbs" "templ" ];
# };
2023-08-11 09:08:09 -07:00
nvim-autopairs = {
2023-08-05 08:47:54 -07:00
enable = true;
2024-04-13 16:16:39 -07:00
settings.check_ts = true;
2023-08-05 08:47:54 -07:00
};
2023-07-29 16:01:53 -07:00
treesitter = {
enable = true;
folding = true;
2024-07-16 19:40:21 -07:00
settings = {
indent.enabled = true;
ensureInstalled = [
"rust"
"toml"
"templ"
"go"
"html"
"json"
"css"
2024-09-23 18:47:21 -07:00
"zig"
2024-07-16 19:40:21 -07:00
];
};
2023-07-29 16:01:53 -07:00
};
2023-09-09 18:26:47 -07:00
rainbow-delimiters.enable = true;
treesitter-refactor = {
enable = true;
#highlightCurrentScope.enable = true;
navigation.enable = true;
smartRename.enable = true;
};
2023-07-29 16:01:53 -07:00
2024-03-25 17:35:57 -07:00
comment = {
2023-07-29 16:01:53 -07:00
enable = true;
2024-03-25 17:35:57 -07:00
settings.toggler = {
2023-07-29 16:01:53 -07:00
line = "<C-/>";
block = "<C-'>";
};
};
floaterm = {
enable = true;
position = "auto";
keymaps = {
toggle = "<leader>t";
};
};
2023-08-11 09:08:09 -07:00
telescope.enable = true;
2023-07-29 16:01:53 -07:00
rust-tools.enable = true;
2024-03-16 18:59:27 -07:00
cmp.enable = true;
2023-07-29 16:01:53 -07:00
cmp-nvim-lsp.enable = true;
# Read settings here: https://github.com/mfussenegger/nvim-dap#Usage
# See :help dap.txt, :help dap-mapping and :help dap-api.
cmp-dap.enable = true;
cmp-buffer.enable = true;
2023-07-29 16:01:53 -07:00
cmp-nvim-lsp-signature-help.enable = true;
cmp-nvim-lua.enable = true;
cmp-path.enable = true;
2023-08-11 09:08:09 -07:00
presence-nvim.enable = true;
2023-07-29 16:01:53 -07:00
nix.enable = true;
airline = {
enable = true;
2024-10-06 08:36:03 -07:00
settings.powerline_fonts = 1;
2023-07-29 16:01:53 -07:00
};
};
extraConfigLua = builtins.readFile ./../rsrcs/nvim.lua;
2023-07-29 12:48:45 -07:00
extraPlugins = with pkgs.vimPlugins;
2023-07-29 21:45:26 -07:00
[
2023-08-05 08:47:54 -07:00
telescope-file-browser-nvim
2023-07-29 21:45:26 -07:00
monokai-pro-nvim
2023-07-29 16:01:53 -07:00
nvim-lspconfig
2023-08-11 10:12:15 -07:00
vim-vsnip
2023-07-29 16:01:53 -07:00
hop-nvim
2023-07-29 21:45:26 -07:00
];
};
2023-07-29 12:48:45 -07:00
}