{ config, inputs, pkgs, lib, ... }: let in with lib; { options = { nixvim = { enable = mkEnableOption "enable k9s"; theme = mkOption { type = types.str; default = "latte"; description = "Catppuccin theme variant for k9s."; }; lsp_jobb = mkEnableOption "enable jobb lsps"; }; }; config = mkIf config.nixvim.enable { programs.nixvim = { enable = true; package = inputs.neovim-nightly-overlay.packages.${pkgs.stdenv.hostPlatform.system}.default; colorschemes = { catppuccin = { enable = true; settings = { flavour = config.nixvim.theme; integrations = { telescope = true; treesitter = true; cmp = true; }; }; }; }; opts = { number = true; relativenumber = true; signcolumn = "yes"; tabstop = 4; shiftwidth = 4; swapfile = false; wrap = true; termguicolors = true; winborder = "rounded"; }; clipboard.register = "unnamedplus"; globals.mapleader = " "; keymaps = [ # Telescope { mode = "n"; key = "f"; action = "Telescope find_files"; } { mode = "n"; key = "o"; action = "Telescope live_grep"; } # Substitute { mode = "n"; key = "s"; action = "lua require('substitute').operator()"; } { mode = "n"; key = "ss"; action = "lua require('substitute').line()"; } { mode = "n"; key = "S"; action = "lua require('substitute').eol()"; } { mode = "x"; key = "s"; action = "lua require('substitute').visual()"; } # LSP { mode = "n"; key = "lf"; action = "lua vim.lsp.buf.format()"; } { mode = "n"; key = "go"; action = "lua vim.diagnostic.open_float()"; } { mode = "n"; key = "gd"; action = ""; options.silent = true; } { mode = "n"; key = "gg"; action = "LazyGit"; } # Navigation fixes for wrap { mode = "n"; key = "j"; action = "gj"; options.silent = true; } { mode = "n"; key = "k"; action = "gk"; options.silent = true; } # Buffers { mode = "n"; key = ""; action = ":bnext"; } { mode = "n"; key = ""; action = ":bprevious"; } { mode = "n"; key = "c"; action = ":bdelete"; } # Window movement { mode = "n"; key = ""; action = "wincmd k"; } { mode = "n"; key = ""; action = "wincmd j"; } { mode = "n"; key = ""; action = "wincmd h"; } { mode = "n"; key = ""; action = "wincmd l"; } # Save / quit { mode = "n"; key = "w"; action = ":w"; } { mode = "n"; key = "q"; action = ":qa"; } # Oil { mode = "n"; key = "-"; action = "Oil"; } { mode = "n"; key = "h"; action = "Oil"; } ]; plugins = { web-devicons.enable = true; cmp-spell.enable = true; lualine = { enable = true; settings = { options.theme = "catppuccin"; tabline = { lualine_a = [ "mode" ]; lualine_b = [ "branch" "diagnostics" ]; lualine_c = [ ]; lualine_x = [ ]; lualine_y = [ "buffers" ]; lualine_z = [ ]; }; }; }; treesitter = { enable = true; grammarPackages = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [ bash json lua make markdown helm nix regex toml vim vimdoc xml yaml ]; }; oil = { enable = true; settings = { default_file_explorer = true; columns = [ "icon" ]; win_options = { wrap = false; signcolumn = "no"; }; }; }; auto-session.enable = true; comment.enable = true; which-key.enable = true; nvim-autopairs.enable = true; vim-surround.enable = true; lazygit.enable = true; telescope.enable = true; luasnip.enable = true; cmp = { enable = true; settings = { mapping = { "" = "cmp.mapping.complete()"; "" = "cmp.mapping.scroll_docs(-4)"; "" = "cmp.mapping.close()"; "" = "cmp.mapping.scroll_docs(4)"; "" = "cmp.mapping.confirm({ select = true })"; "" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})"; "" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})"; }; sources = [ { name = "nvim_lsp"; } { name = "luasnip"; } # { name = "spell"; } ]; }; }; lsp = { enable = true; servers = { gopls.enable = true; nixd.enable = true; lua_ls.enable = true; bashls.enable = true; tinymist.enable = true; tinymist.settings.formatterMode = "typstyle"; yamlls.enable = true; jsonls.enable = true; ts_ls.enable = true; helm_ls.enable = true; nginx_language_server.enable = config.nixvim.lsp_jobb; dockerls.enable = config.nixvim.lsp_jobb; docker_compose_language_service.enable = config.nixvim.lsp_jobb; omnisharp.enable = config.nixvim.lsp_jobb; }; }; }; enableMan = false; autoCmd = [ { event = [ "BufRead" "BufNewFile" ]; pattern = "*.{md,typ}"; command = "setlocal spell spelllang=en,sv"; } # { # event = [ # "BufRead" # "BufNewFile" # ]; # pattern = "*.{md,typ}"; # command = "setlocal spell spelllang=en"; # } ]; }; }; }