From fe0e613928323f9dc538f1bdea8138456abffc4b Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Tue, 17 Sep 2024 18:14:22 +0200 Subject: create nix configuration --- common/home/nixvim/default.nix | 209 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 common/home/nixvim/default.nix (limited to 'common/home/nixvim') diff --git a/common/home/nixvim/default.nix b/common/home/nixvim/default.nix new file mode 100644 index 0000000..047768d --- /dev/null +++ b/common/home/nixvim/default.nix @@ -0,0 +1,209 @@ +{ 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 = { + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.abort()"; + "" = "cmp.mapping.confirm({ select = true })"; + "" = '' + 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("luasnip-expand-or-jump", true, true, true), "") + else + fallback() + end + end, { "i", "s" }) + ''; + "" = '' + 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("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; + }; + keymaps.lspBuf = { + "gd" = "definition"; + "gD" = "references"; + "gt" = "type_definition"; + "gi" = "implementation"; + "K" = "hover"; + "rn" = "rename"; + "ca" = "code_action"; + "f" = "format"; + }; + }; + + lsp-format = { + enable = true; + }; + }; + + globals = { + mapleader = ","; + }; + + keymaps = [ + { + key = "tf"; + action = "NvimTreeToggle"; + mode = "n"; + } + { + key = "f"; + action = "lua require('telescope.builtin').find_files()"; + mode = "n"; + } + { + key = "d"; + action = "lua vim.diagnostic.open_float()"; + mode = "n"; + } + ]; +} -- cgit v1.2.3-70-g09d2