From a61dc3d12ae0300a1a9bef3f97763e8b5a8572fc Mon Sep 17 00:00:00 2001 From: "Casper V. Kristensen" Date: Wed, 9 Aug 2023 03:24:30 +0200 Subject: [PATCH] Some vim config --- modules/base/default.nix | 6 +-- modules/base/vim.nix | 30 ----------- modules/base/vim/config.lua | 100 +++++++++++++++++++++++++++++++++++ modules/base/vim/config.vim | 44 +++++++++++++++ modules/base/vim/default.nix | 37 +++++++++++++ 5 files changed, 183 insertions(+), 34 deletions(-) delete mode 100644 modules/base/vim.nix create mode 100644 modules/base/vim/config.lua create mode 100644 modules/base/vim/config.vim create mode 100644 modules/base/vim/default.nix diff --git a/modules/base/default.nix b/modules/base/default.nix index 441e433..632e8bf 100644 --- a/modules/base/default.nix +++ b/modules/base/default.nix @@ -1,6 +1,4 @@ -{ ... }: - -{ +{ ... }: { imports = [ ./fish.nix ./git.nix @@ -10,6 +8,6 @@ ./ssh.nix ./system.nix ./users.nix - ./vim.nix + ./vim ]; } diff --git a/modules/base/vim.nix b/modules/base/vim.nix deleted file mode 100644 index 8514c56..0000000 --- a/modules/base/vim.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ home-manager, pkgs, ... }: { - home-manager.users.caspervk = { - programs.neovim = { - enable = true; - defaultEditor = true; - viAlias = true; - vimAlias = true; - vimdiffAlias = true; - plugins = with pkgs.vimPlugins; [ - vim-sleuth - ]; - extraPackages = with pkgs; [ ]; - extraConfig = '' - set number - set relativenumber - - set scrolloff=3 - - set ignorecase - set smartcase - - set tabstop=4 - set softtabstop=4 - set shiftwidth=4 - set expandtab - ''; - }; - }; - environment.variables.EDITOR = "vim"; -} diff --git a/modules/base/vim/config.lua b/modules/base/vim/config.lua new file mode 100644 index 0000000..be1bdbd --- /dev/null +++ b/modules/base/vim/config.lua @@ -0,0 +1,100 @@ +-- https://github.com/rebelot/kanagawa.nvim +require('kanagawa').setup({ + undercurl = true, + commentStyle = {italic = false}, + keywordStyle = {italic = false}, + theme = "dragon", + background = { + dark = "dragon", + light = "lotus" + } +}) + +-- https://github.com/lukas-reineke/indent-blankline.nvim +require('indent_blankline').setup({ + show_current_context = true, +}) + +-- https://github.com/numToStr/Comment.nvim +require("Comment").setup() + +-- https://github.com/ggandor/leap.nvim/ +require("leap").add_default_mappings() + +-- https://github.com/NvChad/nvim-colorizer.lua +require('colorizer').setup({user_default_options = {names = false}}) + +-- https://github.com/nvim-treesitter/nvim-treesitter +require('nvim-treesitter.configs').setup({ + highlight = { + enable = true + }, + refactor = { + highlight_definitions = { + enable = true, + clear_on_cursor_move = true, + }, + smart_rename = { + enable = true, + keymaps = { + smart_rename = "grr" + } + }, + navigation = { + enable = true, + keymaps = { + goto_definition = "gnd", + list_definitions = "gnD", + list_definitions_toc = "gO", + goto_next_usage = "", + goto_previous_usage = "", + } + }, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + node_decremental = "", + scope_incremental = false, + } + }, + matchup = { + enable = true, + }, + textobjects = { + swap = { + enable = true, + swap_next = {["a"] = "@parameter.inner"}, + swap_previous = {["A"] = "@parameter.inner"} + } + }, +}) + +-- https://github.com/nvim-treesitter/nvim-treesitter-context +require('treesitter-context').setup({ + mode = "topline", +}) + + +-- https://github.com/nvim-tree/nvim-tree.lua +require("nvim-tree").setup({ + -- Automatically show tree from the project root + -- https://github.com/ahmedkhalf/project.nvim + sync_root_with_cwd = true, + respect_buf_cwd = true, + update_focused_file = { + enable = true, + update_root = true, + }, +}) + + +-- https://github.com/ahmedkhalf/project.nvim +require("project_nvim").setup() + + +-- TODO +require("nvim-dap-virtual-text").setup() + diff --git a/modules/base/vim/config.vim b/modules/base/vim/config.vim new file mode 100644 index 0000000..8e3f502 --- /dev/null +++ b/modules/base/vim/config.vim @@ -0,0 +1,44 @@ +" Colour scheme +colorscheme kanagawa +set termguicolors + +" Show relative line numbers and highlight the current one +set number +set relativenumber +set cursorline +set cursorlineopt=number + +" Keep some context above and below the cursor +set scrolloff=5 +set sidescrolloff=3 + +" Tabs are spaces +set tabstop=4 +set softtabstop=4 +set shiftwidth=4 +set expandtab + +" Better search +set ignorecase +set smartcase + +" Jump to new splits automatically +set splitbelow +set splitright + +" Visualise trailing whitespace +set list +set listchars=trail:·,nbsp:␣ + +" Spelling +set spell +set spelllang=en_us,en_gb,da_dk + +" Use space as leader key +nnoremap +let mapleader = "\" + +" Keep visual selection after indenting +vnoremap > >gv +vnoremap <