From e356b4fa8e02f839394910e7206dd8368c00b89d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 16 Feb 2023 18:03:55 +0100 Subject: [PATCH] add nvim config --- flake.nix | 1 + modules/programs/default.nix | 2 +- .../programs/{vim.nix => nvim/default.nix} | 13 +++ modules/programs/nvim/init.lua | 88 +++++++++++++++++++ 4 files changed, 103 insertions(+), 1 deletion(-) rename modules/programs/{vim.nix => nvim/default.nix} (52%) create mode 100644 modules/programs/nvim/init.lua diff --git a/flake.nix b/flake.nix index 1157fa1..945aaf5 100644 --- a/flake.nix +++ b/flake.nix @@ -148,6 +148,7 @@ nixpkgs-fmt.enable = true; statix.enable = true; shellcheck.enable = true; + stylua.enable = true; }; }; diff --git a/modules/programs/default.nix b/modules/programs/default.nix index abc4c23..a588494 100644 --- a/modules/programs/default.nix +++ b/modules/programs/default.nix @@ -28,7 +28,7 @@ ./ssh.nix ./sway.nix ./thunar.nix - ./vim.nix + ./nvim ./xmonad ./zathura.nix ./zsh.nix diff --git a/modules/programs/vim.nix b/modules/programs/nvim/default.nix similarity index 52% rename from modules/programs/vim.nix rename to modules/programs/nvim/default.nix index 8e3759b..1c00cf5 100644 --- a/modules/programs/vim.nix +++ b/modules/programs/nvim/default.nix @@ -24,6 +24,19 @@ in vimdiffAlias = true; withNodeJs = true; withPython3 = true; + extraLuaConfig = builtins.readFile ./init.lua; + plugins = with pkgs.vimPlugins; [ + catppuccin-nvim + dashboard-nvim + neogit + noice-nvim + nui-nvim # for noice-nvim + nvim-treesitter.withAllGrammars + nvim-web-devicons # for dashboard-nvim + plenary-nvim # for telescope, neogit + telescope-nvim + which-key-nvim + ]; }; }; } diff --git a/modules/programs/nvim/init.lua b/modules/programs/nvim/init.lua new file mode 100644 index 0000000..1cb5fce --- /dev/null +++ b/modules/programs/nvim/init.lua @@ -0,0 +1,88 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = "," + +-- FIX to create spell dir if not existent +local spelldir = vim.fn.stdpath("data") .. "/site/spell" +if not vim.loop.fs_stat(spelldir) then + vim.fn.mkdir(spelldir, "p") +end + +vim.opt.autoindent = true +vim.opt.backupdir = { vim.fn.stdpath("state") .. "/nvim/backup//" } -- don't store backup in files dir +vim.opt.clipboard = "unnamedplus" -- sync with system clipboard +vim.opt.conceallevel = 2 +vim.opt.expandtab = true -- spaces instead of tabs +vim.opt.guifont = "Fira Code Nerd Font:h1" +vim.opt.ignorecase = true +vim.opt.mouse = "a" -- mouse for all modes +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.scrolloff = 4 -- lines of context +vim.opt.shiftround = true -- round indent +vim.opt.shiftwidth = 0 -- use tabstop value +vim.opt.shortmess:append({ c = true }) +vim.opt.signcolumn = "yes" +vim.opt.smartcase = true +vim.opt.splitbelow = true +vim.opt.splitright = true +vim.opt.tabstop = 2 +vim.opt.termguicolors = true +vim.opt.undofile = true +vim.opt.undolevels = 10000 +vim.opt.updatetime = 300 +vim.opt_local.spell = true +vim.opt_local.spelllang = { "en", "de_20" } -- all English regions and new German spelling + +-- plugins +require("catppuccin").setup({ + flavour = "macchiato", +}) +vim.cmd.colorscheme("catppuccin") + +vim.o.timeout = true +vim.o.timeoutlen = 300 +local wk = require("which-key") + +require("noice").setup({ + lsp = { + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, + }, + }, + -- you can enable a preset for easier configuration + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, +}) + +wk.register({ + f = { + name="find", + f = { "Telescope find_files", "find file" }, + g = { "Telescope live_grep", "live grep" }, + b = { "Telescope buffers", "find buffer" }, + }, +}, { prefix = "" }) + +require("neogit").setup({ + disable_commit_confirmation = true, +}) +wk.register({ + g = { "Neogit", "git" } +}, { prefix = ""}) + +require("nvim-treesitter.configs").setup({ + sync_install = false, + auto_install = false, + highlight = { + enable = true, + additional_vim_regex_highlighting = true, + }, +})