neovim!
This commit is contained in:
parent
797553ec11
commit
ee7d831347
4 changed files with 187 additions and 2 deletions
|
@ -1,7 +1,9 @@
|
||||||
{ lib, config, pkgs, ... }: {
|
{ lib, config, pkgs, ... }: {
|
||||||
|
|
||||||
|
|
||||||
home-manager.useGlobalPkgs = true;
|
home-manager.useGlobalPkgs = true;
|
||||||
home-manager.users.sammy = {
|
home-manager.users.sammy = {
|
||||||
|
imports = [ ./neovim.nix ];
|
||||||
home.username = "sammy";
|
home.username = "sammy";
|
||||||
home.homeDirectory = "/home/sammy";
|
home.homeDirectory = "/home/sammy";
|
||||||
home.stateVersion = "23.11"; # Please read the comment before changing.
|
home.stateVersion = "23.11"; # Please read the comment before changing.
|
||||||
|
@ -32,8 +34,6 @@
|
||||||
nushell = {
|
nushell = {
|
||||||
enable = true;
|
enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Home Manager is pretty good at managing dotfiles. The primary way to manage
|
# Home Manager is pretty good at managing dotfiles. The primary way to manage
|
||||||
|
|
62
modules/common/neovim.nix
Normal file
62
modules/common/neovim.nix
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
{ config, pkgs, inputs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
programs.neovim =
|
||||||
|
let
|
||||||
|
toLua = str: "lua << EOF\n${str}\nEOF\n";
|
||||||
|
toLuaFile = file: "lua << EOF\n${builtins.readFile file}\nEOF\n";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
viAlias = true;
|
||||||
|
vimAlias = true;
|
||||||
|
vimdiffAlias = true;
|
||||||
|
|
||||||
|
extraPackages = with pkgs; [
|
||||||
|
lua-language-server
|
||||||
|
rnix-lsp
|
||||||
|
|
||||||
|
xclip
|
||||||
|
wl-clipboard
|
||||||
|
];
|
||||||
|
|
||||||
|
plugins = with pkgs.vimPlugins; [
|
||||||
|
|
||||||
|
{
|
||||||
|
plugin = comment-nvim;
|
||||||
|
config = toLua "require(\"Comment\").setup()";
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
plugin = catppuccin-nvim;
|
||||||
|
config = "colorscheme catppuccin";
|
||||||
|
}
|
||||||
|
|
||||||
|
{ plugin = which-key-nvim;
|
||||||
|
config = toLua "require(\"which-key\").setup()";
|
||||||
|
}
|
||||||
|
|
||||||
|
nvim-cmp
|
||||||
|
neodev-nvim
|
||||||
|
|
||||||
|
cmp_luasnip
|
||||||
|
cmp-nvim-lsp
|
||||||
|
|
||||||
|
luasnip
|
||||||
|
friendly-snippets
|
||||||
|
|
||||||
|
|
||||||
|
lualine-nvim
|
||||||
|
nvim-web-devicons
|
||||||
|
|
||||||
|
vim-nix
|
||||||
|
];
|
||||||
|
|
||||||
|
extraLuaConfig = ''
|
||||||
|
${builtins.readFile ./nvim/options.lua}
|
||||||
|
${builtins.readFile ./nvim/keymap.lua}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
69
modules/common/nvim/keymap.lua
Normal file
69
modules/common/nvim/keymap.lua
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
local map = vim.keymap.set
|
||||||
|
local wk = require("which-key")
|
||||||
|
|
||||||
|
-- better up/down
|
||||||
|
map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
|
||||||
|
map({ "n", "x" }, "<Down>", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
|
||||||
|
map({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
|
||||||
|
map({ "n", "x" }, "<Up>", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
|
||||||
|
|
||||||
|
-- Move to window using the <ctrl> hjkl keys
|
||||||
|
map("n", "<C-h>", "<C-w>h", { desc = "Go to left window", remap = true })
|
||||||
|
map("n", "<C-j>", "<C-w>j", { desc = "Go to lower window", remap = true })
|
||||||
|
map("n", "<C-k>", "<C-w>k", { desc = "Go to upper window", remap = true })
|
||||||
|
map("n", "<C-l>", "<C-w>l", { desc = "Go to right window", remap = true })
|
||||||
|
|
||||||
|
-- Resize window using <ctrl> arrow keys
|
||||||
|
map("n", "<C-Up>", "<cmd>resize +2<cr>", { desc = "Increase window height" })
|
||||||
|
map("n", "<C-Down>", "<cmd>resize -2<cr>", { desc = "Decrease window height" })
|
||||||
|
map("n", "<C-Left>", "<cmd>vertical resize -2<cr>", { desc = "Decrease window width" })
|
||||||
|
map("n", "<C-Right>", "<cmd>vertical resize +2<cr>", { desc = "Increase window width" })
|
||||||
|
|
||||||
|
-- Move Lines
|
||||||
|
map("n", "<A-j>", "<cmd>m .+1<cr>==", { desc = "Move down" })
|
||||||
|
map("n", "<A-k>", "<cmd>m .-2<cr>==", { desc = "Move up" })
|
||||||
|
map("i", "<A-j>", "<esc><cmd>m .+1<cr>==gi", { desc = "Move down" })
|
||||||
|
map("i", "<A-k>", "<esc><cmd>m .-2<cr>==gi", { desc = "Move up" })
|
||||||
|
map("v", "<A-j>", ":m '>+1<cr>gv=gv", { desc = "Move down" })
|
||||||
|
map("v", "<A-k>", ":m '<-2<cr>gv=gv", { desc = "Move up" })
|
||||||
|
|
||||||
|
-- buffers
|
||||||
|
map("n", "<S-h>", "<cmd>bprevious<cr>", { desc = "Prev buffer" })
|
||||||
|
map("n", "<S-l>", "<cmd>bnext<cr>", { desc = "Next buffer" })
|
||||||
|
|
||||||
|
-- Clear search with <esc>
|
||||||
|
map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", { desc = "Escape and clear hlsearch" })
|
||||||
|
|
||||||
|
-- save file
|
||||||
|
map({ "i", "x", "n", "s" }, "<C-s>", "<cmd>w<cr><esc>", { desc = "Save file" })
|
||||||
|
|
||||||
|
--keywordprg
|
||||||
|
map("n", "<leader>K", "<cmd>norm! K<cr>", { desc = "Keywordprg" })
|
||||||
|
|
||||||
|
-- better indenting
|
||||||
|
map("v", "<", "<gv")
|
||||||
|
map("v", ">", ">gv")
|
||||||
|
|
||||||
|
wk.register({["<leader>f"] = { name = "File" }})
|
||||||
|
-- new file
|
||||||
|
map("n", "<leader>fn", "<cmd>enew<cr>", { desc = "New File" })
|
||||||
|
|
||||||
|
map("n", "<leader>xl", "<cmd>lopen<cr>", { desc = "Location List" })
|
||||||
|
map("n", "<leader>xq", "<cmd>copen<cr>", { desc = "Quickfix List" })
|
||||||
|
|
||||||
|
map("n", "<leader>ww", "<C-W>p", { desc = "Other window", remap = true })
|
||||||
|
map("n", "<leader>wd", "<C-W>c", { desc = "Delete window", remap = true })
|
||||||
|
map("n", "<leader>w-", "<C-W>s", { desc = "Split window below", remap = true })
|
||||||
|
map("n", "<leader>w|", "<C-W>v", { desc = "Split window right", remap = true })
|
||||||
|
map("n", "<leader>-", "<C-W>s", { desc = "Split window below", remap = true })
|
||||||
|
map("n", "<leader>|", "<C-W>v", { desc = "Split window right", remap = true })
|
||||||
|
|
||||||
|
-- tabs
|
||||||
|
wk.register({["<leader><tab>"] = { name = "Tabs" }})
|
||||||
|
map("n", "<leader><tab>l", "<cmd>tablast<cr>", { desc = "Last Tab" })
|
||||||
|
map("n", "<leader><tab>f", "<cmd>tabfirst<cr>", { desc = "First Tab" })
|
||||||
|
map("n", "<leader><tab><tab>", "<cmd>tabnew<cr>", { desc = "New Tab" })
|
||||||
|
map("n", "<leader><tab>]", "<cmd>tabnext<cr>", { desc = "Next Tab" })
|
||||||
|
map("n", "<leader><tab>d", "<cmd>tabclose<cr>", { desc = "Close Tab" })
|
||||||
|
map("n", "<leader><tab>[", "<cmd>tabprevious<cr>", { desc = "Previous Tab" })
|
||||||
|
|
54
modules/common/nvim/options.lua
Normal file
54
modules/common/nvim/options.lua
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
-- partially taken from https://www.lazyvim.org and merged with my own config
|
||||||
|
--
|
||||||
|
vim.g.mapleader = " "
|
||||||
|
vim.g.maplocalleader = "\\"
|
||||||
|
|
||||||
|
-- root dir detection
|
||||||
|
vim.g.root_spec = { "lsp", { ".git", "lua" }, "cwd" }
|
||||||
|
|
||||||
|
local opt = vim.opt
|
||||||
|
|
||||||
|
opt.autowrite = true -- Enable auto write
|
||||||
|
opt.autoread = true
|
||||||
|
opt.clipboard = "unnamedplus" -- Sync with system clipboard
|
||||||
|
opt.completeopt = "menu,menuone,noselect"
|
||||||
|
opt.conceallevel = 3 -- Hide * markup for bold and italic
|
||||||
|
opt.confirm = true -- Confirm to save changes before exiting modified buffer
|
||||||
|
opt.cursorline = true -- Enable highlighting of the current line
|
||||||
|
opt.ignorecase = true -- Ignore case in search
|
||||||
|
opt.inccommand = "nosplit" -- preview incremental substitute
|
||||||
|
opt.laststatus = 3 -- global statusline
|
||||||
|
opt.list = true -- Show some invisible characters (tabs...
|
||||||
|
opt.mouse = "a" -- Enable mouse mode
|
||||||
|
opt.number = true -- Print line number
|
||||||
|
opt.pumblend = 10 -- Popup blend
|
||||||
|
opt.pumheight = 10 -- Maximum number of entries in a popup
|
||||||
|
opt.relativenumber = true -- Relative line numbers
|
||||||
|
opt.scrolloff = 4 -- Lines of context
|
||||||
|
opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize", "help", "globals", "skiprtp", "folds" }
|
||||||
|
opt.shiftround = true -- Round indent
|
||||||
|
opt.shiftwidth = 2 -- Size of an indent
|
||||||
|
opt.shortmess:append({ W = true, I = true, c = true, C = true })
|
||||||
|
opt.showmode = false -- Dont show mode since we have a statusline
|
||||||
|
opt.sidescrolloff = 8 -- Columns of context
|
||||||
|
opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time
|
||||||
|
opt.smartcase = true -- Don't ignore case with capitals
|
||||||
|
opt.smartindent = true -- Insert indents automatically
|
||||||
|
opt.spelllang = { "en", "de" }
|
||||||
|
opt.splitbelow = true -- Put new windows below current
|
||||||
|
opt.splitkeep = "screen"
|
||||||
|
opt.splitright = true -- Put new windows right of current
|
||||||
|
opt.tabstop = 2 -- Number of spaces tabs count for
|
||||||
|
opt.termguicolors = true -- True color support
|
||||||
|
opt.timeoutlen = 300
|
||||||
|
opt.undofile = true
|
||||||
|
opt.undolevels = 10000
|
||||||
|
opt.updatetime = 200 -- Save swap file and trigger CursorHold
|
||||||
|
opt.virtualedit = "block" -- Allow cursor to move where there is no text in visual block mode
|
||||||
|
opt.wildmode = "longest:full,full" -- Command-line completion mode
|
||||||
|
opt.winminwidth = 5 -- Minimum window width
|
||||||
|
opt.wrap = false -- Disable line wrap
|
||||||
|
|
||||||
|
-- Fix markdown indentation settings
|
||||||
|
vim.g.markdown_recommended_style = 0
|
||||||
|
|
Loading…
Reference in a new issue