Some vim config

This commit is contained in:
Casper V. Kristensen 2023-08-09 03:24:30 +02:00
parent e4aac5da74
commit a61dc3d12a
5 changed files with 183 additions and 34 deletions

View file

@ -1,6 +1,4 @@
{ ... }:
{
{ ... }: {
imports = [
./fish.nix
./git.nix
@ -10,6 +8,6 @@
./ssh.nix
./system.nix
./users.nix
./vim.nix
./vim
];
}

View file

@ -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";
}

100
modules/base/vim/config.lua Normal file
View file

@ -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 = "<a-*>",
goto_previous_usage = "<a-#>",
}
},
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<C-space>",
node_incremental = "<C-space>",
node_decremental = "<C-M-space>",
scope_incremental = false,
}
},
matchup = {
enable = true,
},
textobjects = {
swap = {
enable = true,
swap_next = {["<leader>a"] = "@parameter.inner"},
swap_previous = {["<leader>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()

View file

@ -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 <Space> <Nop>
let mapleader = "\<Space>"
" Keep visual selection after indenting
vnoremap > >gv
vnoremap < <gv

View file

@ -0,0 +1,37 @@
{ home-manager, pkgs, ... }: {
home-manager.users.caspervk = {
programs.neovim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
plugins = with pkgs.vimPlugins; [
kanagawa-nvim # colorscheme
vim-sleuth # automatic tab width
vim-surround # surrounding textobjects
indent-blankline-nvim # indentation guides
comment-nvim # comment keybinds
nvim-colorizer-lua # show colours in colours
leap-nvim # mouse, but its a keyboard
nvim-treesitter.withAllGrammars # code parser
nvim-treesitter-refactor # treesitter highlights and refactor keybinds
nvim-treesitter-textobjects # syntax-aware text objects
nvim-treesitter-context # context at the top of the screen
vim-matchup # better %
nvim-tree-lua # file explorer
nvim-web-devicons # file icons for nvim-tree
project-nvim # project management; mostly for nvim-tree
nvim-dap # debug adapter protocol
nvim-dap-virtual-text # show variable values in-line
];
extraPackages = with pkgs; [ ];
extraConfig = builtins.readFile ./config.vim;
extraLuaConfig = builtins.readFile ./config.lua;
};
};
environment.variables.EDITOR = "vim";
}