diff options
Diffstat (limited to 'modules/neovim')
| -rw-r--r-- | modules/neovim/default.nix | 55 | ||||
| -rw-r--r-- | modules/neovim/keybinds.lua | 41 | ||||
| -rw-r--r-- | modules/neovim/settings.lua | 50 |
3 files changed, 146 insertions, 0 deletions
diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix new file mode 100644 index 0000000..775f420 --- /dev/null +++ b/modules/neovim/default.nix @@ -0,0 +1,55 @@ +{ config, lib, pkgs, ...}: +let + cfg = config.modules.neovim; + lua = str: "lua << EOF\n${str}\nEOF\n"; + luaImport = file: "lua << EOF\n${builtins.readFile file}\nEOF\n"; +in +{ + options.modules.neovim = { + enable = lib.mkEnableOption "neovim"; + }; + + config = { + programs.neovim = lib.mkIf cfg.enable { + enable = true; + defaultEditor = true; + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + plugins = with pkgs.vimPlugins; [ + { + plugin = nvim-lspconfig; + config = let + servers = [ + { name = "clangd"; } + ]; + in lua (pkgs.lib.strings.concatStrings (pkgs.lib.lists.forEach servers (s: "require('lspconfig')['${s.name}'].setup(${s.config or "{}"})\n"))); + } + + (nvim-treesitter.withPlugins (p: with p; [ + tree-sitter-nix + tree-sitter-c + tree-sitter-lua + tree-sitter-zig + tree-sitter-markdown + tree-sitter-markdown-inline + ])) + + { + plugin = neorg; + config = lua '' + require("neorg").setup() + ''; + } + base16-nvim + telescope-nvim + telescope-fzf-native-nvim + ]; + extraLuaConfig = '' + ${builtins.readFile ./settings.lua} + ${builtins.readFile ./keybinds.lua} + require("neorg").setup() + ''; + }; + }; +} diff --git a/modules/neovim/keybinds.lua b/modules/neovim/keybinds.lua new file mode 100644 index 0000000..cbd46c5 --- /dev/null +++ b/modules/neovim/keybinds.lua @@ -0,0 +1,41 @@ +local map = vim.keymap.set + +local function nmap(lhs, rhs, opts) + map('n', lhs, rhs, opts) +end + +local function swap(mode, bind1, bind2) + local tmp=bind1 + map(mode, bind1, bind2) + map(mode, bind2, tmp) +end + +local function swapnv(bind1, bind2) + swap({'n', 'v'}, bind1, bind2) +end + +swapnv('m', 'h') +swapnv('n', 'j') +swapnv('e', 'k') +swapnv('i', 'l') + +swapnv('M', 'H') +swapnv('N', 'J') +--swapnv('E', 'K') +swapnv('I', 'L') + +nmap('<leader>tn', ':tabnew<CR>', { desc = "Open a new tab" }) +nmap('<leader>tc', ':tabc<CR>', { desc = "Close the current tab" }) +nmap('<leader>tm', ':tabp<CR>', { desc = "Go to previous tab" }) +nmap('<leader>ti', ':tabn<CR>', { desc = "Go to next tab" }) + +nmap('<leader>wv', ':vne<CR>', { desc = "Create vertical split" }) +nmap('<leader>wh', ':new<CR>', { desc = "Create horizontal split" }) +nmap('<leader>wc', ':clo<CR>', { desc = "Close current window" }) + +nmap('<leader>wm', '<C-w><C-h>', { desc = "Focus window left of the current one" }) +nmap('<leader>wn', '<C-w><C-j>', { desc = "Focus window below the current one" }) +nmap('<leader>we', '<C-w><C-k>', { desc = "Focus window above the current one" }) +nmap('<leader>wi', '<C-w><C-l>', { desc = "Focus window right of the current one" }) + +nmap('<leader>fo', '<cmd>Telescope find_files<CR>', { silent = true }) diff --git a/modules/neovim/settings.lua b/modules/neovim/settings.lua new file mode 100644 index 0000000..816757c --- /dev/null +++ b/modules/neovim/settings.lua @@ -0,0 +1,50 @@ +vim.g.mapleader = ' ' + +vim.o.number = true +vim.o.relativenumber = true +vim.o.splitright = true +vim.o.splitbelow = true +vim.o.scrolloff = 15 +vim.o.wrap = false +vim.o.lbr = true +vim.o.shortmess = vim.o.shortmess .. "I" +vim.o.termguicolors = true +vim.opt.fillchars = {eob = " "} +--vim.o.smd = false +--vim.opt.laststatus = 3 +vim.opt.pumheight = 6 +vim.opt.shiftwidth = 8 +vim.opt.tabstop = 8 +vim.opt.expandtab = true +vim.o.mouse="" +vim.o.guicursor="" +vim.o.swapfile=false + +vim.cmd[[ + colorscheme base16-mountain + hi LineNr guifg=#ceb188 + hi LineNrAbove guifg=#262626 + hi LineNrBelow guifg=#262626 + hi CursorLineNr guifg=#ceb188 guibg=#191919 gui=bold + hi FloatBorder guifg=#4c4c4c + hi Pmenu guibg=#0d0d0d + hi PmenuSel guibg=#191919 guifg=#cacaca + hi WinBar guifg=#4c4c4c + hi WinSeparator guifg=#191919 + + " status line + hi StatusLine guibg=#191919 guifg=#4c4c4c + hi StatuslineInactive guibg=#191919 guifg=#4c4c4c gui=NONE + hi StatuslineAccent guifg=#0f0f0f guibg=#aca98a gui=bold + hi StatuslineInsertAccent guifg=#0f0f0f guibg=#8aabac gui=bold + hi StatuslineVisualAccent guifg=#0f0f0f guibg=#8f8aac gui=bold + hi StatuslineReplaceAccent guifg=#0f0f0f guibg=#ac8a8c gui=bold + hi StatuslineTerminalAccent guifg=#0f0f0f guibg=#ac8a8c gui=bold + hi StatuslineCommandAccent guifg=#0f0f0f guibg=#8aac8b gui=bold + hi StatuslineFileIcon guibg=#191919 guifg=#8f8aac + hi StatuslineInfo guibg=#191919 guifg=#4c4c4c + hi LspError guibg=#191919 guifg=#c49ea0 + hi LspWarn guibg=#191919 guifg=#8f8aac + hi LspInfo guibg=#191919 guifg=#8f8aac + hi LspHint guibg=#191919 guifg=#8aabac +]] |