nixos/home-manager/modules/nvim.nix

307 lines
7.5 KiB
Nix
Raw Permalink Normal View History

2024-03-01 08:23:28 +01:00
{ inputs, pkgs, ... }: {
imports = [ inputs.nixvim.homeManagerModules.nixvim ];
# Nixvim
programs.nixvim = {
enable = true;
viAlias = true;
vimAlias = true;
2024-03-16 18:17:16 +01:00
keymaps = [
{
action = "<cmd>Oil<cr>";
key = "<leader>e";
options = { silent = true; };
}
{
2024-03-16 18:26:22 +01:00
action =
"<cmd>lua require('conform').format({ bufnr = buf, lsp_fallback = true })<cr>";
2024-03-16 18:17:16 +01:00
key = "<leader>f";
options = { silent = true; };
}
];
2024-03-30 17:29:21 +01:00
opts = {
hlsearch = false;
incsearch = true;
number = true;
relativenumber = true;
tabstop = 4;
softtabstop = 4;
shiftwidth = 4;
expandtab = true;
smartindent = true;
mouse = "";
breakindent = true;
undofile = true;
swapfile = true;
ignorecase = true;
smartcase = true;
signcolumn = "yes";
completeopt = "menuone,noselect";
updatetime = 50;
timeoutlen = 300;
colorcolumn = "80";
showmode = false;
laststatus = 3;
splitbelow = true;
splitright = true;
};
2024-03-01 08:23:28 +01:00
globals = {
mapleader = " ";
maplocalleader = ";";
};
2024-03-01 08:23:28 +01:00
extraConfigLuaPre = ''
2024-03-24 21:25:16 +01:00
local autocmd = vim.api.nvim_create_autocmd
local augroup = vim.api.nvim_create_augroup
-- General Settings
local general = augroup("General Settings", { clear = true })
autocmd("BufEnter", {
callback = function()
vim.opt.formatoptions:remove { "c", "r", "o" }
end,
group = general,
desc = "Disable New Line Comment",
})
2024-03-01 08:23:28 +01:00
'';
extraConfigLuaPost = ''
2024-03-16 18:24:39 +01:00
vim.notify = require("mini.notify").make_notify()
2024-03-01 08:23:28 +01:00
'';
2024-03-21 16:51:07 +01:00
extraPackages = with pkgs; [
stylua
isort
black
2024-04-04 21:56:41 +02:00
nixfmt-classic
2024-03-21 16:51:07 +01:00
jq
shfmt
ripgrep
prettierd
2024-04-17 13:41:25 +02:00
perl538Packages.PerlTidy
perl538Packages.PerlCritic
2024-03-21 16:51:07 +01:00
];
plugins = {
2024-03-30 15:46:31 +01:00
comment.enable = true;
ts-context-commentstring.enable = true;
todo-comments.enable = true;
lspkind = {
enable = true;
cmp.enable = true;
};
indent-blankline = {
enable = true;
2024-03-30 15:46:31 +01:00
settings.scope.enabled = false;
};
cmp = {
enable = true;
settings = {
mapping = {
"<C-l>" = "cmp.mapping.confirm({ select = true })";
"<C-j>" = ''
function(fallback)
if cmp.visible then
cmp.select_next_item()
else
fallback()
end
end
'';
"<C-k>" = ''
function(fallback)
if cmp.visible then
2024-03-23 11:07:07 +01:00
cmp.select_prev_item()
else
fallback()
end
end
'';
"<C-Space>" = "cmp.mapping.complete()";
"<C-e>" = "cmp.mapping.abort()";
"<C-u>" = "cmp.mapping.scroll_docs(-4)";
"<C-d>" = "cmp.mapping.scroll_docs(4)";
};
snippet.expand = ''
function(args)
require('snippy').expand_snippet(args.body)
end
'';
sources =
[ { name = "nvim_lsp"; } { name = "path"; } { name = "snippy"; } ];
};
};
2024-03-10 20:13:50 +01:00
conform-nvim = {
enable = true;
formattersByFt = {
2024-03-16 13:13:51 +01:00
json = [ "jq" ];
2024-03-10 20:13:50 +01:00
lua = [ "stylua" ];
python = [ "isort" "black" ];
nix = [ "nixfmt" ];
2024-03-16 13:13:51 +01:00
sh = [ "shfmt" ];
2024-03-23 19:59:18 +01:00
bash = [ "shfmt" ];
zsh = [ "zsh" ];
2024-03-21 16:51:07 +01:00
html = [ "prettierd" ];
css = [ "prettierd" ];
2024-04-17 13:41:25 +02:00
perl = [ "perltidy" ];
2024-03-10 20:13:50 +01:00
};
};
lint = {
enable = true;
lintersByFt = {
python = [ "mypy" ];
ruby = [ "ruby" ];
2024-04-19 07:39:48 +02:00
# sh = [ "shellcheck" ];
# bash = [ "shellcheck" ];
# zsh = [ "shellcheck" ];
2024-04-17 13:41:25 +02:00
perl = [ "perlcritic" ];
2024-03-10 20:13:50 +01:00
};
};
2024-03-01 08:23:28 +01:00
harpoon = {
enable = true;
keymaps = {
addFile = "<leader>a";
toggleQuickMenu = "<C-e>";
2024-03-01 08:23:28 +01:00
navFile = {
"1" = "<C-j>";
"2" = "<C-k>";
"3" = "<C-l>";
"4" = "<C-;>";
};
};
};
oil = {
enable = true;
2024-03-30 15:46:31 +01:00
settings = {
show_hidden = true;
default_file_explorer = true;
};
};
treesitter.enable = true;
gitsigns = {
enable = true;
2024-03-30 15:46:31 +01:00
settings.signs = {
add.text = "";
2024-03-01 08:23:28 +01:00
change.text = "";
changedelete.text = "";
delete.text = "";
topdelete.text = "";
untracked.text = "";
2024-03-30 15:46:31 +01:00
on_attach = ''
function(buffer)
local gs = package.loaded.gitsigns
local function map(mode, l, r, desc)
vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc })
end
-- stylua: ignore start
map("n", "]g", gs.next_hunk, "Next git hunk")
map("n", "[g", gs.prev_hunk, "Previous git hunk")
end
2024-03-30 15:46:31 +01:00
'';
};
};
mini = {
enable = true;
2024-03-01 08:23:28 +01:00
modules = {
statusline = { set_vim_settings = false; };
notify = { };
};
};
2024-03-01 08:23:28 +01:00
telescope = {
enable = true;
2024-03-01 08:23:28 +01:00
extensions = {
fzf-native = {
enable = true;
2024-04-12 14:14:17 +02:00
settings = {
fuzzy = true;
override_generic_sorter = true;
override_file_sorter = true;
case_mode = "smart_case";
};
};
2024-03-01 08:23:28 +01:00
ui-select.enable = true;
};
keymaps = {
"<leader>pf" = "find_files";
"<C-p>" = "git_files";
"<leader>vh" = "help_tags";
"<leader>ps" = "grep_string";
};
};
lsp = {
enable = true;
servers = {
lua-ls.enable = true;
nil_ls.enable = true;
marksman.enable = true;
2024-03-03 10:32:54 +01:00
gopls.enable = true;
2024-03-07 19:17:20 +01:00
pyright.enable = true;
2024-03-21 16:51:07 +01:00
html.enable = true;
emmet_ls.enable = true;
cssls.enable = true;
2024-03-23 19:59:18 +01:00
bashls.enable = true;
2024-04-17 13:41:25 +02:00
perlpls.enable = true;
};
keymaps = {
diagnostic = {
"<leader>vd" = "open_float";
"[d" = "goto_next";
"]d" = "goto_prev";
};
lspBuf = {
K = "hover";
gd = "definition";
gD = "declaration";
gi = "implementation";
"<leader>lca" = "code_action";
"<leader>lrn" = "rename";
"<C-h>" = "signature_help";
};
};
preConfig = ''
local function sign_define(args)
vim.fn.sign_define(args.name, {
texthl = args.name,
text = args.text,
numhl = "",
})
end
2024-03-01 08:23:28 +01:00
sign_define({ name = "DiagnosticSignError", text = "E" })
sign_define({ name = "DiagnosticSignWarn", text = "W" })
sign_define({ name = "DiagnosticSignHint", text = "H" })
sign_define({ name = "DiagnosticSignInfo", text = "I" })
2024-03-01 08:23:28 +01:00
'';
};
};
colorschemes.catppuccin = {
enable = true;
2024-04-16 15:06:58 +02:00
settings = {
flavour = "frappe";
styles = {
functions = [ "bold" ];
keywords = [ "bold" ];
};
};
};
2024-03-01 08:23:28 +01:00
extraPlugins = with pkgs.vimPlugins; [ vim-snippets ];
};
}