summaryrefslogtreecommitdiff
path: root/common/home/programs/nixvim/default.nix
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2024-09-18 18:58:59 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2024-09-18 18:58:59 +0200
commitebb67feeb46226dff0d384c7800dab4e42a03912 (patch)
treed3e91ce8dace5770792f4633b31ecea93988bc5c /common/home/programs/nixvim/default.nix
parent04e96de97689d1b78437df4173ece9857d9c6a61 (diff)
refactor home
Diffstat (limited to 'common/home/programs/nixvim/default.nix')
-rw-r--r--common/home/programs/nixvim/default.nix210
1 files changed, 210 insertions, 0 deletions
diff --git a/common/home/programs/nixvim/default.nix b/common/home/programs/nixvim/default.nix
new file mode 100644
index 0000000..628b8d0
--- /dev/null
+++ b/common/home/programs/nixvim/default.nix
@@ -0,0 +1,210 @@
+{ pkgs, ... }:
+{
+ enable = true;
+ defaultEditor = true;
+
+ enableMan = true;
+
+ package = pkgs.unstable.neovim-unwrapped;
+
+ extraConfigLua = ''
+ local signs = { Error = "󰀨 ", Warn = " ", Hint = " ", Info = " " }
+ for type, icon in pairs(signs) do
+ local hl = "DiagnosticSign" .. type
+ vim.fn.sign_define(hl, { text = icon, texthl= hl, numhl = hl })
+ end'';
+
+ diagnostics = {
+ virtual_text = {
+ prefix = "󰬨";
+ };
+ };
+
+ opts = {
+ mouse = "a";
+ number = true;
+ softtabstop = 0;
+ expandtab = false;
+ tabstop = 2;
+ shiftwidth = 2;
+ smartindent = true;
+ list = true;
+ listchars = {
+ tab = "> ";
+ eol = "¬";
+ trail = "·";
+ nbsp = "•";
+ };
+ splitright = true;
+ splitbelow = true;
+ showcmd = true;
+ wildmenu = true;
+ hlsearch = true;
+ autoread = true;
+ swapfile = false;
+ };
+
+ clipboard = {
+ register = "unnamedplus";
+ providers.wl-copy.enable = true;
+ };
+
+ colorschemes.base16 = {
+ enable = true;
+ colorscheme = "gruvbox-dark-pale";
+ };
+
+ plugins = {
+ nvim-tree = {
+ enable = true;
+ autoClose = true;
+ disableNetrw = true;
+ hijackCursor = true;
+ };
+
+ telescope = {
+ enable = true;
+ };
+
+ lualine = {
+ enable = true;
+ };
+
+ treesitter = {
+ enable = true;
+ settings = {
+ auto_install = false;
+ ensure_installed = "all";
+ highlight = {
+ additional_vim_regex_highlighting = true;
+ enable = true;
+ };
+ ignore_install = [ "rust" ];
+ incremental_selection = {
+ enable = true;
+ keymaps = {
+ init_selection = false;
+ node_decremental = "grm";
+ node_incremental = "grn";
+ scope_incremental = "grc";
+ };
+ };
+ indent = {
+ enable = true;
+ };
+ sync_install = false;
+ };
+ };
+
+ luasnip = {
+ enable = true;
+ };
+
+ friendly-snippets = {
+ enable = true;
+ };
+
+ cmp = {
+ enable = true;
+ autoEnableSources = true;
+ settings = {
+ mapping = {
+ "<C-b>" = "cmp.mapping.scroll_docs(-4)";
+ "<C-f>" = "cmp.mapping.scroll_docs(4)";
+ "<C-Space>" = "cmp.mapping.complete()";
+ "<C-e>" = "cmp.mapping.abort()";
+ "<CR>" = "cmp.mapping.confirm({ select = true })";
+ "<Tab>" = ''
+ cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_next_item()
+ elseif require("luasnip").expand_or_jumpable() then
+ vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plugin>luasnip-expand-or-jump", true, true, true), "")
+ else
+ fallback()
+ end
+ end, { "i", "s" })
+ '';
+ "<S-Tab>" = ''
+ cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_prev_item()
+ elseif require("luasnip").jumpable(-1) then
+ vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plugin>luasnip-jump-prev", true, true, true), "")
+ else
+ fallback()
+ end
+ end, { "i", "s" })
+ '';
+ };
+ snippet = {
+ expand = "function(args) require('luasnip').lsp_expand(args.body) end";
+ };
+ sources = [
+ { name = "nvim_lsp"; }
+ { name = "luasnip"; }
+ { name = "path"; }
+ { name = "buffer"; }
+ ];
+ };
+ };
+
+ lsp = {
+ enable = true;
+ servers = {
+ bashls = {
+ enable = true;
+ package = pkgs.unstable.bash-language-server;
+ };
+ clangd.enable = true;
+ nixd = {
+ enable = true;
+ settings.formatting.command = [ "nixfmt" ];
+ };
+ rust-analyzer = {
+ enable = true;
+ installCargo = true;
+ installRustc = true;
+ };
+ pyright.enable = true;
+ ocamllsp.enable = true;
+ };
+ keymaps.lspBuf = {
+ "gd" = "definition";
+ "gD" = "references";
+ "gt" = "type_definition";
+ "gi" = "implementation";
+ "K" = "hover";
+ "rn" = "rename";
+ "<space>ca" = "code_action";
+ "<space>f" = "format";
+ };
+ };
+
+ lsp-format = {
+ enable = true;
+ };
+ };
+
+ globals = {
+ mapleader = ",";
+ };
+
+ keymaps = [
+ {
+ key = "<leader>tf";
+ action = "<cmd>NvimTreeToggle<cr>";
+ mode = "n";
+ }
+ {
+ key = "<leader>f";
+ action = "<cmd>lua require('telescope.builtin').find_files()<cr>";
+ mode = "n";
+ }
+ {
+ key = "<space>d";
+ action = "<cmd>lua vim.diagnostic.open_float()<cr>";
+ mode = "n";
+ }
+ ];
+}