From 98f4a6679e0c5d6aaa1dab096a1f6f48d4dfa553 Mon Sep 17 00:00:00 2001 From: Dennis Date: Fri, 24 Jan 2025 21:49:07 +0100 Subject: [PATCH] Adds nvim config as home manager module --- .../nvim/config/after/ftplugin/markdown.vim | 5 + home/modules/nvim/config/init.lua | 16 ++ home/modules/nvim/config/lazy-lock.json | 48 ++++ home/modules/nvim/config/lua/dnsc/keymaps.lua | 8 + home/modules/nvim/config/lua/dnsc/lazy.lua | 79 ++++++ home/modules/nvim/config/lua/dnsc/leader.lua | 5 + home/modules/nvim/config/lua/dnsc/options.lua | 44 +++ home/modules/nvim/config/lua/dnsc/utils.lua | 39 +++ .../nvim/config/lua/plugins/barbar.lua | 18 ++ .../nvim/config/lua/plugins/diffview.lua | 4 + .../nvim/config/lua/plugins/gitlinker.lua | 5 + .../nvim/config/lua/plugins/gitsigns.lua | 42 +++ home/modules/nvim/config/lua/plugins/go.lua | 22 ++ .../nvim/config/lua/plugins/harpoon.lua | 39 +++ .../nvim/config/lua/plugins/helpers.lua | 4 + home/modules/nvim/config/lua/plugins/ibl.lua | 16 ++ .../nvim/config/lua/plugins/lazygit.lua | 19 ++ home/modules/nvim/config/lua/plugins/lsp.lua | 268 ++++++++++++++++++ .../nvim/config/lua/plugins/lualine.lua | 19 ++ .../nvim/config/lua/plugins/mini.pairs.lua | 4 + .../nvim/config/lua/plugins/null-ls.lua | 93 ++++++ .../nvim/config/lua/plugins/nvim-surround.lua | 6 + .../nvim/config/lua/plugins/obsidian.lua | 28 ++ home/modules/nvim/config/lua/plugins/oil.lua | 8 + .../nvim/config/lua/plugins/substitute.lua | 16 ++ .../nvim/config/lua/plugins/telescope.lua | 20 ++ .../modules/nvim/config/lua/plugins/theme.lua | 58 ++++ .../nvim/config/lua/plugins/todo-comments.lua | 7 + .../nvim/config/lua/plugins/treesitter.lua | 97 +++++++ .../nvim/config/lua/plugins/vim-dadbod-ui.lua | 20 ++ .../nvim/config/lua/plugins/which-key.lua | 185 ++++++++++++ .../nvim/config/lua/plugins/zen-mode.lua | 4 + home/modules/nvim/config/stylua.toml | 9 + home/modules/nvim/default.nix | 5 + 34 files changed, 1260 insertions(+) create mode 100644 home/modules/nvim/config/after/ftplugin/markdown.vim create mode 100644 home/modules/nvim/config/init.lua create mode 100644 home/modules/nvim/config/lazy-lock.json create mode 100644 home/modules/nvim/config/lua/dnsc/keymaps.lua create mode 100644 home/modules/nvim/config/lua/dnsc/lazy.lua create mode 100644 home/modules/nvim/config/lua/dnsc/leader.lua create mode 100644 home/modules/nvim/config/lua/dnsc/options.lua create mode 100644 home/modules/nvim/config/lua/dnsc/utils.lua create mode 100644 home/modules/nvim/config/lua/plugins/barbar.lua create mode 100644 home/modules/nvim/config/lua/plugins/diffview.lua create mode 100644 home/modules/nvim/config/lua/plugins/gitlinker.lua create mode 100644 home/modules/nvim/config/lua/plugins/gitsigns.lua create mode 100644 home/modules/nvim/config/lua/plugins/go.lua create mode 100644 home/modules/nvim/config/lua/plugins/harpoon.lua create mode 100644 home/modules/nvim/config/lua/plugins/helpers.lua create mode 100644 home/modules/nvim/config/lua/plugins/ibl.lua create mode 100644 home/modules/nvim/config/lua/plugins/lazygit.lua create mode 100644 home/modules/nvim/config/lua/plugins/lsp.lua create mode 100644 home/modules/nvim/config/lua/plugins/lualine.lua create mode 100644 home/modules/nvim/config/lua/plugins/mini.pairs.lua create mode 100644 home/modules/nvim/config/lua/plugins/null-ls.lua create mode 100644 home/modules/nvim/config/lua/plugins/nvim-surround.lua create mode 100644 home/modules/nvim/config/lua/plugins/obsidian.lua create mode 100644 home/modules/nvim/config/lua/plugins/oil.lua create mode 100644 home/modules/nvim/config/lua/plugins/substitute.lua create mode 100644 home/modules/nvim/config/lua/plugins/telescope.lua create mode 100644 home/modules/nvim/config/lua/plugins/theme.lua create mode 100644 home/modules/nvim/config/lua/plugins/todo-comments.lua create mode 100644 home/modules/nvim/config/lua/plugins/treesitter.lua create mode 100644 home/modules/nvim/config/lua/plugins/vim-dadbod-ui.lua create mode 100644 home/modules/nvim/config/lua/plugins/which-key.lua create mode 100644 home/modules/nvim/config/lua/plugins/zen-mode.lua create mode 100644 home/modules/nvim/config/stylua.toml create mode 100644 home/modules/nvim/default.nix diff --git a/home/modules/nvim/config/after/ftplugin/markdown.vim b/home/modules/nvim/config/after/ftplugin/markdown.vim new file mode 100644 index 0000000..629290d --- /dev/null +++ b/home/modules/nvim/config/after/ftplugin/markdown.vim @@ -0,0 +1,5 @@ +setlocal expandtab +setlocal smartindent +setlocal tabstop=2 +setlocal shiftwidth=2 +setlocal conceallevel=2 diff --git a/home/modules/nvim/config/init.lua b/home/modules/nvim/config/init.lua new file mode 100644 index 0000000..1a700e1 --- /dev/null +++ b/home/modules/nvim/config/init.lua @@ -0,0 +1,16 @@ +--[[ +███╗ ██╗██╗ ██╗██╗███╗ ███╗ +████╗ ██║██║ ██║██║████╗ ████║ +██╔██╗ ██║██║ ██║██║██╔████╔██║ +██║╚██╗██║╚██╗ ██╔╝██║██║╚██╔╝██║ +██║ ╚████║ ╚████╔╝ ██║██║ ╚═╝ ██║ +╚═╝ ╚═══╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ + +Config Author: Dennis Schoepf +Version: 1.0.0 +]] +-- + +require("dnsc.lazy") +require("dnsc.utils") +require("dnsc.keymaps") diff --git a/home/modules/nvim/config/lazy-lock.json b/home/modules/nvim/config/lazy-lock.json new file mode 100644 index 0000000..7c61b33 --- /dev/null +++ b/home/modules/nvim/config/lazy-lock.json @@ -0,0 +1,48 @@ +{ + "LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" }, + "barbar.nvim": { "branch": "master", "commit": "53b5a2f34b68875898f0531032fbf090e3952ad7" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, + "gitlinker.nvim": { "branch": "master", "commit": "296ad98061ca31706a7d890a0f13baed6e137c79" }, + "gitsigns.nvim": { "branch": "main", "commit": "d8918f06624dd53b9a82bd0e29c31bcfd541b40d" }, + "go.nvim": { "branch": "master", "commit": "6e5a74b866aa4a112ed85a1169befff2ef82c027" }, + "guihua.lua": { "branch": "master", "commit": "d783191eaa75215beae0c80319fcce5e6b3beeda" }, + "harpoon": { "branch": "harpoon2", "commit": "a84ab829eaf3678b586609888ef52f7779102263" }, + "indent-blankline.nvim": { "branch": "master", "commit": "e10626f7fcd51ccd56d7ffc00883ba7e0aa28f78" }, + "lazy.nvim": { "branch": "main", "commit": "d8f26efd456190241afd1b0f5235fe6fdba13d4a" }, + "lazygit.nvim": { "branch": "main", "commit": "77a0d42943d8265271e6e6beaed72da54eeb17e7" }, + "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "e942edf5c85b6a2ab74059ea566cac5b3e1514a4" }, + "mason-null-ls.nvim": { "branch": "main", "commit": "de19726de7260c68d94691afb057fa73d3cc53e7" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "mini.pairs": { "branch": "main", "commit": "7e834c5937d95364cc1740e20d673afe2d034cdb" }, + "none-ls-extras.nvim": { "branch": "main", "commit": "6557f20e631d2e9b2a9fd27a5c045d701a3a292c" }, + "none-ls.nvim": { "branch": "main", "commit": "ed8f80849ef1ad31c2f74679fafdef7801091247" }, + "nvim-cmp": { "branch": "main", "commit": "12509903a5723a876abd65953109f926f4634c30" }, + "nvim-lspconfig": { "branch": "master", "commit": "0ef64599b8aa0187ee5f6d92cb39c951f348f041" }, + "nvim-surround": { "branch": "main", "commit": "ae298105122c87bbe0a36b1ad20b06d417c0433e" }, + "nvim-treesitter": { "branch": "master", "commit": "51562d44fc6280f92bb9a3d87e7b3cb327377ca5" }, + "nvim-web-devicons": { "branch": "master", "commit": "aafa5c187a15701a7299a392b907ec15d9a7075f" }, + "obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" }, + "oil.nvim": { "branch": "master", "commit": "52f1683c7664819508e1d2fc85051d4a20c5d643" }, + "orgmode": { "branch": "master", "commit": "056c21762df23e4f2263aca0c717a064fd2095ff" }, + "plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" }, + "rose-pine": { "branch": "main", "commit": "42f0724e0bca9f57f0bcfa688787c37b8d4befe8" }, + "schemastore.nvim": { "branch": "main", "commit": "bb52c530698654355bbddb9f0035dc35cea401a5" }, + "substitute.nvim": { "branch": "main", "commit": "97f49d16f8eea7967d41db4f657dd63af53eeba1" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" }, + "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, + "vim-cool": { "branch": "master", "commit": "662e7b11064cbeedad17c45d2fe926e78d3cd0b6" }, + "vim-dadbod": { "branch": "master", "commit": "96997dac981d50717a63d4dbd48d4a43e09ecf57" }, + "vim-dadbod-completion": { "branch": "master", "commit": "95cbcf21ea7a5c8c025f387280c2e261b8cb3a89" }, + "vim-dadbod-ssh": { "branch": "master", "commit": "9bce775ee76c3dd6d7508dcd9eb276b36133d710" }, + "vim-dadbod-ui": { "branch": "master", "commit": "65454e2011c029922c2c972d63f8bf04282de033" }, + "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, + "which-key.nvim": { "branch": "main", "commit": "6cebd86917df559a88de0f806b2989799c6e6423" }, + "zen-mode.nvim": { "branch": "main", "commit": "863f150ca321b3dd8aa1a2b69b5f411a220e144f" } +} diff --git a/home/modules/nvim/config/lua/dnsc/keymaps.lua b/home/modules/nvim/config/lua/dnsc/keymaps.lua new file mode 100644 index 0000000..2bfe0a6 --- /dev/null +++ b/home/modules/nvim/config/lua/dnsc/keymaps.lua @@ -0,0 +1,8 @@ +local opts = { noremap = true, silent = true, expr = true } + +vim.keymap.set("n", "k", "v:count == 0 ? 'gk' : 'k'", opts) +vim.keymap.set("n", "j", "v:count == 0 ? 'gj' : 'j'", opts) +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") diff --git a/home/modules/nvim/config/lua/dnsc/lazy.lua b/home/modules/nvim/config/lua/dnsc/lazy.lua new file mode 100644 index 0000000..9ac8d16 --- /dev/null +++ b/home/modules/nvim/config/lua/dnsc/lazy.lua @@ -0,0 +1,79 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +local opts = { noremap = true, silent = true, expr = true } + +vim.g.mapleader = " " +vim.g.maplocalleader = " " +vim.keymap.set("", "", "", opts) + +local options = { + backup = false, -- creates a backup file + clipboard = "unnamedplus", -- allows neovim to access the system clipboard + cmdheight = 1, -- more space in the neovim command line for displaying messages + completeopt = { "menu", "menuone", "noselect" }, -- mostly just for cmp + conceallevel = 0, -- so that `` is visible in markdown files + fileencoding = "utf-8", -- the encoding written to a file + hlsearch = true, -- highlight all matches on previous search pattern + ignorecase = true, -- ignore case in search patterns + mouse = "a", -- allow the mouse to be used in neovim + pumheight = 10, -- pop up menu height + showmode = false, -- we don't need to see things like -- INSERT -- anymore + smartindent = true, + breakindent = true, + showtabline = 0, -- always show tabs + smartcase = true, -- smart case + splitbelow = true, -- force all horizontal splits to go below current window + splitright = true, -- force all vertical splits to go to the right of current window + swapfile = false, -- creates a swapfile + termguicolors = true, -- set term gui colors (most terminals support this) + timeoutlen = 200, -- time to wait for a mapped sequence to complete (in milliseconds) + undofile = true, -- enable persistent undo + updatetime = 230, -- faster completion (4000ms default) + writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited + expandtab = true, -- convert tabs to spaces + shiftwidth = 2, -- the number of spaces inserted for each indentation + tabstop = 2, -- insert 2 spaces for a tab + cursorline = true, -- highlight the current line + number = true, -- set numbered lines + relativenumber = true, -- set relative numbered lines + numberwidth = 4, -- set number column width to 2 {default 4} + signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time + linebreak = true, + breakat = " ^I!@*-+;:,./?", + scrolloff = 6, -- is one of my fav + sidescrolloff = 4, + winbar = nil, +} + +vim.opt.shortmess:append("c") + +for k, v in pairs(options) do + vim.opt[k] = v +end + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "rose-pine" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) diff --git a/home/modules/nvim/config/lua/dnsc/leader.lua b/home/modules/nvim/config/lua/dnsc/leader.lua new file mode 100644 index 0000000..22eacc8 --- /dev/null +++ b/home/modules/nvim/config/lua/dnsc/leader.lua @@ -0,0 +1,5 @@ +local opts = { noremap = true, silent = true, expr = true } + +vim.g.mapleader = " " +vim.g.maplocalleader = " " +vim.keymap.set("", "", "", opts) diff --git a/home/modules/nvim/config/lua/dnsc/options.lua b/home/modules/nvim/config/lua/dnsc/options.lua new file mode 100644 index 0000000..2627229 --- /dev/null +++ b/home/modules/nvim/config/lua/dnsc/options.lua @@ -0,0 +1,44 @@ +local options = { + backup = false, -- creates a backup file + clipboard = "unnamedplus", -- allows neovim to access the system clipboard + cmdheight = 1, -- more space in the neovim command line for displaying messages + completeopt = { "menu", "menuone", "noselect" }, -- mostly just for cmp + conceallevel = 0, -- so that `` is visible in markdown files + fileencoding = "utf-8", -- the encoding written to a file + hlsearch = true, -- highlight all matches on previous search pattern + ignorecase = true, -- ignore case in search patterns + mouse = "a", -- allow the mouse to be used in neovim + pumheight = 10, -- pop up menu height + showmode = false, -- we don't need to see things like -- INSERT -- anymore + smartindent = true, + breakindent = true, + showtabline = 0, -- always show tabs + smartcase = true, -- smart case + splitbelow = true, -- force all horizontal splits to go below current window + splitright = true, -- force all vertical splits to go to the right of current window + swapfile = false, -- creates a swapfile + termguicolors = true, -- set term gui colors (most terminals support this) + timeoutlen = 200, -- time to wait for a mapped sequence to complete (in milliseconds) + undofile = true, -- enable persistent undo + updatetime = 230, -- faster completion (4000ms default) + writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited + expandtab = true, -- convert tabs to spaces + shiftwidth = 2, -- the number of spaces inserted for each indentation + tabstop = 2, -- insert 2 spaces for a tab + cursorline = true, -- highlight the current line + number = true, -- set numbered lines + relativenumber = true, -- set relative numbered lines + numberwidth = 4, -- set number column width to 2 {default 4} + signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time + linebreak = true, + breakat = " ^I!@*-+;:,./?", + scrolloff = 6, -- is one of my fav + sidescrolloff = 4, + winbar = nil, +} + +vim.opt.shortmess:append("c") + +for k, v in pairs(options) do + vim.opt[k] = v +end diff --git a/home/modules/nvim/config/lua/dnsc/utils.lua b/home/modules/nvim/config/lua/dnsc/utils.lua new file mode 100644 index 0000000..2d76d4b --- /dev/null +++ b/home/modules/nvim/config/lua/dnsc/utils.lua @@ -0,0 +1,39 @@ +-- Highlight on yank +local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true }) + +vim.api.nvim_create_autocmd("TextYankPost", { + callback = function() + vim.highlight.on_yank() + end, + group = highlight_group, + pattern = "*", +}) + +local function filter(arr, fn) + if type(arr) ~= "table" then + return arr + end + + local filtered = {} + for k, v in pairs(arr) do + if fn(v, k, arr) then + table.insert(filtered, v) + end + end + + return filtered +end + +local function filterReactDTS(value) + -- Depending on typescript version either uri or targetUri is returned + if value.uri then + return string.match(value.uri, "%.d.ts") == nil + elseif value.targetUri then + return string.match(value.targetUri, "%.d.ts") == nil + end +end + +return { + filter = filter, + filterReactDTS = filterReactDTS, +} diff --git a/home/modules/nvim/config/lua/plugins/barbar.lua b/home/modules/nvim/config/lua/plugins/barbar.lua new file mode 100644 index 0000000..d783df9 --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/barbar.lua @@ -0,0 +1,18 @@ +return { + "romgrk/barbar.nvim", + dependencies = { + "lewis6991/gitsigns.nvim", -- OPTIONAL: for git status + "nvim-tree/nvim-web-devicons", -- OPTIONAL: for file icons + }, + init = function() + vim.g.barbar_auto_setup = false + end, + opts = { + animation = false, + auto_hide = false, + maximum_length = 35, + icons = { filetype = { enabled = false }, button = "", modified = { button = "m" } }, + highlight_visible = false, + }, + version = "^1.0.0", -- optional: only update when a new 1.x version is released +} diff --git a/home/modules/nvim/config/lua/plugins/diffview.lua b/home/modules/nvim/config/lua/plugins/diffview.lua new file mode 100644 index 0000000..f1b4e4f --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/diffview.lua @@ -0,0 +1,4 @@ +return { + "sindrets/diffview.nvim", + opts = {}, +} diff --git a/home/modules/nvim/config/lua/plugins/gitlinker.lua b/home/modules/nvim/config/lua/plugins/gitlinker.lua new file mode 100644 index 0000000..84da08a --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/gitlinker.lua @@ -0,0 +1,5 @@ +return { + "linrongbin16/gitlinker.nvim", + cmd = "GitLink", + opts = {}, +} diff --git a/home/modules/nvim/config/lua/plugins/gitsigns.lua b/home/modules/nvim/config/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..f90bfb1 --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/gitsigns.lua @@ -0,0 +1,42 @@ +return { + "lewis6991/gitsigns.nvim", + opts = { + signs = { + add = { text = "│" }, + change = { text = "│" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + untracked = { text = "┆" }, + }, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = false, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + watch_gitdir = { + interval = 1000, + follow_files = true, + }, + attach_to_untracked = true, + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + ignore_whitespace = false, + }, + current_line_blame_formatter = ", - ", + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, -- Disable if file is longer than this (in lines) + preview_config = { + -- Options passed to nvim_open_win + border = "single", + style = "minimal", + relative = "cursor", + row = 0, + col = 1, + }, + }, +} diff --git a/home/modules/nvim/config/lua/plugins/go.lua b/home/modules/nvim/config/lua/plugins/go.lua new file mode 100644 index 0000000..e913bff --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/go.lua @@ -0,0 +1,22 @@ +return { + "ray-x/go.nvim", + dependencies = { -- optional packages + "ray-x/guihua.lua", + "neovim/nvim-lspconfig", + "nvim-treesitter/nvim-treesitter", + }, + event = { "CmdlineEnter" }, + ft = { "go", "gomod" }, + build = ':lua require("go.install").update_all_sync()', -- if you need to install/update all binaries + opts = {}, + init = function() + local format_sync_grp = vim.api.nvim_create_augroup("goimports", {}) + vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*.go", + callback = function() + require("go.format").goimports() + end, + group = format_sync_grp, + }) + end, +} diff --git a/home/modules/nvim/config/lua/plugins/harpoon.lua b/home/modules/nvim/config/lua/plugins/harpoon.lua new file mode 100644 index 0000000..fe0c6d8 --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/harpoon.lua @@ -0,0 +1,39 @@ +return { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local harpoon = require("harpoon") + + harpoon:setup() + + vim.keymap.set("n", "ha", function() + harpoon:list():add() + end) + + vim.keymap.set("n", "hx", function() + harpoon:list():select(1) + end) + vim.keymap.set("n", "hc", function() + harpoon:list():select(2) + end) + vim.keymap.set("n", "hv", function() + harpoon:list():select(3) + end) + vim.keymap.set("n", "hs", function() + harpoon:list():select(4) + end) + + vim.keymap.set("n", "hp", function() + harpoon:list():prev() + end) + + vim.keymap.set("n", "hn", function() + harpoon:list():next() + end) + + vim.keymap.set("n", "hh", function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end) + end, +} diff --git a/home/modules/nvim/config/lua/plugins/helpers.lua b/home/modules/nvim/config/lua/plugins/helpers.lua new file mode 100644 index 0000000..1192bf8 --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/helpers.lua @@ -0,0 +1,4 @@ +return { + "romainl/vim-cool", + "tpope/vim-sleuth", +} diff --git a/home/modules/nvim/config/lua/plugins/ibl.lua b/home/modules/nvim/config/lua/plugins/ibl.lua new file mode 100644 index 0000000..1fbd4ce --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/ibl.lua @@ -0,0 +1,16 @@ +return { + "lukas-reineke/indent-blankline.nvim", + main = "ibl", + ---@module "ibl" + ---@type ibl.config + opts = { + indent = { + smart_indent_cap = false, + char = "╎", + }, + scope = { + show_start = false, + show_end = false, + }, + }, +} diff --git a/home/modules/nvim/config/lua/plugins/lazygit.lua b/home/modules/nvim/config/lua/plugins/lazygit.lua new file mode 100644 index 0000000..be438f4 --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/lazygit.lua @@ -0,0 +1,19 @@ +return { + "kdheepak/lazygit.nvim", + cmd = { + "LazyGit", + "LazyGitConfig", + "LazyGitCurrentFile", + "LazyGitFilter", + "LazyGitFilterCurrentFile", + }, + -- optional for floating window border decoration + dependencies = { + "nvim-lua/plenary.nvim", + }, + -- setting the keybinding for LazyGit with 'keys' is recommended in + -- order to load the plugin when the command is run for the first time + keys = { + { "lg", "LazyGit", desc = "LazyGit" }, + }, +} diff --git a/home/modules/nvim/config/lua/plugins/lsp.lua b/home/modules/nvim/config/lua/plugins/lsp.lua new file mode 100644 index 0000000..e9289d7 --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/lsp.lua @@ -0,0 +1,268 @@ +return { + "neovim/nvim-lspconfig", + version = "0.1.9", + dependencies = { + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/nvim-cmp", + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "b0o/schemastore.nvim", + }, + config = function() + local lspconfig = require("lspconfig") + local luasnip = require("luasnip") + local dnscUtils = require("dnsc.utils") + local lspUtils = require("lspconfig.util") + local cmp = require("cmp") + local capabilities = require("cmp_nvim_lsp").default_capabilities() + + local servers = { + "angularls", + "ts_ls", + "lua_ls", + "jsonls", + "html", + "cssls", + "tailwindcss", + "gopls", + "astro", + "tinymist", + } + + require("mason").setup() + -- Automatic Server Installation with Mason + require("mason-lspconfig").setup({ + ensure_installed = servers, + automatic_installation = true, + }) + + -- LANGUAGE SERVERS + -- Lua + lspconfig.lua_ls.setup({ + capabilities = capabilities, + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + telemetry = { + enable = false, + }, + }, + }, + }) + + -- Typescript + lspconfig.tsserver.setup({ + capabilities = capabilities, + root_dir = lspUtils.root_pattern("package.json"), + init_options = { + preferences = { + importModuleSpecifierPreference = "relative", + importModuleSpecifierEnding = "minimal", + }, + }, + handlers = { + ["textDocument/definition"] = function(err, result, method, ...) + if vim.tbl_islist(result) and #result > 1 then + local filtered_result = dnscUtils.filter(result, dnscUtils.filterReactDTS) + return vim.lsp.handlers["textDocument/definition"](err, filtered_result, method, ...) + end + + vim.lsp.handlers["textDocument/definition"](err, result, method, ...) + end, + }, + }) + + -- JSON + lspconfig.jsonls.setup({ + capabilities = capabilities, + settings = { + json = { + schemas = require("schemastore").json.schemas(), + validate = { enable = true }, + }, + }, + }) + + -- HTML + lspconfig.html.setup({ + capabilities = capabilities, + }) + + -- Astro + lspconfig.astro.setup({}) + + -- Tailwind + lspconfig.tailwindcss.setup({}) + + -- Typst + lspconfig.tinymist.setup({ + single_file_support = true, + root_dir = function() + return vim.fn.getcwd() + end, + settings = {}, + }) + + -- CSS + lspconfig.cssls.setup({}) + + -- Angular + lspconfig.angularls.setup({}) + + -- Go + lspconfig.gopls.setup({ + capabilities = capabilities, + }) + + -- Run gofmt + goimports on save + local format_sync_grp = vim.api.nvim_create_augroup("goimports", {}) + vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*.go", + callback = function() + require("go.format").goimports() + end, + group = format_sync_grp, + }) + + -- LSP Keybindings + -- Global mappings. + -- See `:help vim.diagnostic.*` for documentation on any of the below functions + vim.keymap.set("n", "e", vim.diagnostic.open_float) + vim.keymap.set("n", "[d", vim.diagnostic.goto_prev) + vim.keymap.set("n", "]d", vim.diagnostic.goto_next) + vim.keymap.set("n", "q", vim.diagnostic.setloclist) + + -- Use LspAttach autocommand to only map the following keys + -- after the language server attaches to the current buffer + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + callback = function(ev) + -- Enable completion triggered by + vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc" + + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local opts = { buffer = ev.buf } + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) + vim.keymap.set("n", "", vim.lsp.buf.signature_help, opts) + vim.keymap.set("n", "D", vim.lsp.buf.type_definition, opts) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) + vim.keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) + vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) + vim.keymap.set("n", "f", function() + vim.lsp.buf.format({ async = true }) + end, opts) + end, + }) + + cmp.setup({ + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) -- For `luasnip` users. + end, + }, + formatting = { + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = string.format("%s ", vim_item.kind) -- This concatenates the icons with the name of the item kind + -- Source + vim_item.menu = ({ + buffer = "[Buffer]", + nvim_lsp = "[LSP]", + luasnip = "[Snip]", + nvim_lua = "[Lua]", + })[entry.source.name] + return vim_item + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + if luasnip.expandable() then + luasnip.expand() + else + cmp.confirm({ + select = true, + }) + end + else + fallback() + end + end), + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.locally_jumpable(1) then + luasnip.jump(1) + else + fallback() + end + end, { "i", "s" }), + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp", keyword_length = 1 }, + { name = "path" }, + { name = "buffer", keyword_length = 3 }, + { name = "luasnip" }, -- For luasnip users. + }), + }) + + -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline({ "/", "?" }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, + }) + + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), + }) + + -- Set up vim-dadbod completions + cmp.setup.filetype({ "sql", "mysql", "psql" }, { + sources = { + { name = "vim-dadbod-completion" }, + { name = "buffer" }, + }, + }) + + -- Set up org mode + cmp.setup.filetype({ "org" }, { + sources = { + { name = "orgmode" }, + }, + }) + end, +} diff --git a/home/modules/nvim/config/lua/plugins/lualine.lua b/home/modules/nvim/config/lua/plugins/lualine.lua new file mode 100644 index 0000000..9644717 --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/lualine.lua @@ -0,0 +1,19 @@ +return { + "nvim-lualine/lualine.nvim", + opts = { + options = { + icons_enabled = false, + -- globalstatus = true + component_separators = { left = "|", right = "|" }, + section_separators = { left = "", right = "" }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = {}, + lualine_c = { "branch", "diff", "diagnostics" }, + lualine_x = { "filetype", "encoding" }, + lualine_y = {}, + lualine_z = { "location" }, + }, + }, +} diff --git a/home/modules/nvim/config/lua/plugins/mini.pairs.lua b/home/modules/nvim/config/lua/plugins/mini.pairs.lua new file mode 100644 index 0000000..666d1de --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/mini.pairs.lua @@ -0,0 +1,4 @@ +return { + "echasnovski/mini.pairs", + opts = {}, +} diff --git a/home/modules/nvim/config/lua/plugins/null-ls.lua b/home/modules/nvim/config/lua/plugins/null-ls.lua new file mode 100644 index 0000000..360df59 --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/null-ls.lua @@ -0,0 +1,93 @@ +return { + "jay-babu/mason-null-ls.nvim", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "williamboman/mason.nvim", + "nvimtools/none-ls.nvim", + "nvimtools/none-ls-extras.nvim", + "neovim/nvim-lspconfig", + }, + config = function() + local lsp = require("lspconfig") + local null_ls = require("null-ls") + local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + + local string_starts_with = function(str, start) + return string.sub(str, 1, #start) == start + end + + local create_runtime_condition = function(config_names) + local bufnr_cache = {} + local config_path_cache = {} + + return function(params) + if bufnr_cache[params.bufnr] ~= nil then + return bufnr_cache[params.bufnr] + else + for _, cached_config_path in ipairs(config_path_cache) do + if string_starts_with(params.bufname, cached_config_path) then + bufnr_cache[params.bufnr] = true + return true + end + end + end + + local config_path = lsp.util.root_pattern(config_names)(params.bufname) + + local has_config = config_path ~= nil + if has_config then + table.insert(config_path_cache, config_path) + end + bufnr_cache[params.bufnr] = has_config + + return has_config + end + end + + local eslint_runtime_condition = create_runtime_condition({ + ".eslintrc.cjs", + ".eslintrc.js", + ".eslintrc.json", + ".eslintrc.yaml", + ".eslintrc.yml", + }) + + require("null-ls").setup({ + root_dir = require("null-ls.utils").root_pattern(".null-ls-root", "package.json", ".git"), + sources = { + -- null_ls.builtins.diagnostics.markdownlint, + null_ls.builtins.formatting.prettierd, + require("none-ls.code_actions.eslint_d"), + require("none-ls.diagnostics.eslint_d").with({ + runtime_condition = eslint_runtime_condition, + }), + require("none-ls.formatting.eslint_d").with({ + runtime_condition = eslint_runtime_condition, + }), + null_ls.builtins.formatting.stylua, + }, + on_attach = function(current_client, bufnr) + if current_client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format({ + bufnr = bufnr, + filter = function(client) + return client.name == "null-ls" + end, + }) + end, + }) + end + end, + }) + + require("mason-null-ls").setup({ + ensure_installed = nil, + automatic_installation = true, + }) + end, +} diff --git a/home/modules/nvim/config/lua/plugins/nvim-surround.lua b/home/modules/nvim/config/lua/plugins/nvim-surround.lua new file mode 100644 index 0000000..c0bfcb6 --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/nvim-surround.lua @@ -0,0 +1,6 @@ +return { + "kylechui/nvim-surround", + version = "*", -- Use for stability; omit to use `main` branch for the latest features + event = "VeryLazy", + opts = {}, +} diff --git a/home/modules/nvim/config/lua/plugins/obsidian.lua b/home/modules/nvim/config/lua/plugins/obsidian.lua new file mode 100644 index 0000000..e264edb --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/obsidian.lua @@ -0,0 +1,28 @@ +return { + "epwalsh/obsidian.nvim", + version = "*", -- recommended, use latest release instead of latest commit + lazy = true, + ft = "markdown", + event = { + "BufReadPre /home/dennis/notes/**.md", + "BufNewFile /home/dennis/notes/**.md", + }, + opts = { + workspaces = { + { + name = "notes", + path = "~/notes", + }, + }, + daily_notes = { + -- Optional, if you keep daily notes in a separate directory. + folder = "~/notes/001_dailies", + -- Optional, if you want to change the date format for the ID of daily notes. + date_format = "%Y-%m-%d", + -- Optional, if you want to change the date format of the default alias of daily notes. + alias_format = "%B %-d, %Y", + -- Optional, if you want to automatically insert a template from your template directory like 'daily.md' + template = nil, + }, + }, +} diff --git a/home/modules/nvim/config/lua/plugins/oil.lua b/home/modules/nvim/config/lua/plugins/oil.lua new file mode 100644 index 0000000..093b214 --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/oil.lua @@ -0,0 +1,8 @@ +return { + "stevearc/oil.nvim", + opts = { + keymaps = { + ["q"] = "actions.close", + }, + }, +} diff --git a/home/modules/nvim/config/lua/plugins/substitute.lua b/home/modules/nvim/config/lua/plugins/substitute.lua new file mode 100644 index 0000000..71231f3 --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/substitute.lua @@ -0,0 +1,16 @@ +return { + "gbprod/substitute.nvim", + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + }, + config = function() + require("substitute").setup({}) + + vim.keymap.set("n", "s", require("substitute").operator, { noremap = true }) + vim.keymap.set("n", "ss", require("substitute").line, { noremap = true }) + vim.keymap.set("n", "S", require("substitute").eol, { noremap = true }) + vim.keymap.set("x", "s", require("substitute").visual, { noremap = true }) + end, +} diff --git a/home/modules/nvim/config/lua/plugins/telescope.lua b/home/modules/nvim/config/lua/plugins/telescope.lua new file mode 100644 index 0000000..4f30506 --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/telescope.lua @@ -0,0 +1,20 @@ +return { + "nvim-telescope/telescope.nvim", + tag = "0.1.8", + dependencies = { + "nvim-lua/plenary.nvim", + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build", + }, + }, + opts = { + pickers = {}, + extensions = { + fzf = {}, + }, + }, + init = function() + require("telescope").load_extension("fzf") + end, +} diff --git a/home/modules/nvim/config/lua/plugins/theme.lua b/home/modules/nvim/config/lua/plugins/theme.lua new file mode 100644 index 0000000..5729886 --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/theme.lua @@ -0,0 +1,58 @@ +return { + { + "rose-pine/neovim", + name = "rose-pine", + config = function() + require("rose-pine").setup({ + variant = "auto", -- auto, main, moon, or dawn + dark_variant = "main", -- main, moon, or dawn + dim_inactive_windows = false, + extend_background_behind_borders = true, + + enable = { + terminal = true, + migrations = true, + }, + + styles = { + bold = true, + italic = false, + transparency = true, + }, + + groups = { + border = "muted", + link = "iris", + panel = "surface", + + error = "love", + hint = "iris", + info = "foam", + note = "pine", + todo = "rose", + warn = "gold", + + git_add = "foam", + git_change = "rose", + git_delete = "love", + git_dirty = "rose", + git_ignore = "muted", + git_merge = "iris", + git_rename = "pine", + git_stage = "iris", + git_text = "rose", + git_untracked = "subtle", + + h1 = "iris", + h2 = "foam", + h3 = "rose", + h4 = "gold", + h5 = "pine", + h6 = "foam", + }, + }) + + vim.cmd("colorscheme rose-pine") + end, + }, +} diff --git a/home/modules/nvim/config/lua/plugins/todo-comments.lua b/home/modules/nvim/config/lua/plugins/todo-comments.lua new file mode 100644 index 0000000..0b3399a --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/todo-comments.lua @@ -0,0 +1,7 @@ +return { + "folke/todo-comments.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + opts = { + signs = false, + }, +} diff --git a/home/modules/nvim/config/lua/plugins/treesitter.lua b/home/modules/nvim/config/lua/plugins/treesitter.lua new file mode 100644 index 0000000..5957b33 --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/treesitter.lua @@ -0,0 +1,97 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + local configs = require("nvim-treesitter.configs") + + configs.setup({ + ensure_installed = { + "angular", + "bash", + "c", + "css", + "diff", + "html", + "javascript", + "jsdoc", + "json", + "jsonc", + "lua", + "luadoc", + "luap", + "markdown", + "markdown_inline", + "printf", + "python", + "query", + "regex", + "toml", + "tsx", + "typescript", + "vim", + "vimdoc", + "xml", + "yaml", + }, + auto_install = true, + sync_install = false, + ignore_install = {}, + modules = {}, + highlight = { enable = true }, + indent = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = "", + node_decremental = "", + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["aa"] = "@parameter.outer", + ["ia"] = "@parameter.inner", + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + ["]m"] = "@function.outer", + ["]]"] = "@class.outer", + }, + goto_next_end = { + ["]M"] = "@function.outer", + ["]["] = "@class.outer", + }, + goto_previous_start = { + ["[m"] = "@function.outer", + ["[["] = "@class.outer", + }, + goto_previous_end = { + ["[M"] = "@function.outer", + ["[]"] = "@class.outer", + }, + }, + swap = { + enable = true, + swap_next = { + ["a"] = "@parameter.inner", + }, + swap_previous = { + ["A"] = "@parameter.inner", + }, + }, + }, + }) + end, +} diff --git a/home/modules/nvim/config/lua/plugins/vim-dadbod-ui.lua b/home/modules/nvim/config/lua/plugins/vim-dadbod-ui.lua new file mode 100644 index 0000000..5174910 --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/vim-dadbod-ui.lua @@ -0,0 +1,20 @@ +return { + "kristijanhusak/vim-dadbod-ui", + dependencies = { + "pbogut/vim-dadbod-ssh", + { "tpope/vim-dadbod", lazy = true }, + { "kristijanhusak/vim-dadbod-completion", ft = { "sql", "mysql", "plsql" }, lazy = true }, + }, + cmd = { + "DBUI", + "DBUIToggle", + "DBUIAddConnection", + "DBUIFindBuffer", + }, + init = function() + vim.g.db_ui_use_nerd_fonts = 1 + vim.g.dbs = { + { name = "freed_dev", url = "sqlite:./freed.db" }, + } + end, +} diff --git a/home/modules/nvim/config/lua/plugins/which-key.lua b/home/modules/nvim/config/lua/plugins/which-key.lua new file mode 100644 index 0000000..bd9b429 --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/which-key.lua @@ -0,0 +1,185 @@ +return { + "folke/which-key.nvim", + event = "VeryLazy", + opts = { + icons = { mappings = false }, + }, + keys = { + { ".", "Telescope find_files", desc = "Find file in dir", mode = "n" }, + { "", "Telescope git_files", desc = "Find git file", mode = "n" }, + { "B", "Telescope buffers", desc = "Opens buffers", mode = "n" }, + { "b", group = "buffer", mode = "n" }, + { "b,", "BufferMovePrevious", desc = "Move buffer back", mode = "n" }, + { + "b.", + "BufferMoveNext", + desc = "Move buffer forward", + mode = "n", + }, + { + "bD", + "BufferCloseAllButCurrent", + desc = "Delete all buffers but current", + mode = "n", + }, + { + "bd", + "BufferClose", + desc = "Delete current buffer", + mode = "n", + }, + { + "bh", + "BufferPrevious", + desc = "Go to previous buffer", + mode = "n", + }, + { + "bl", + "BufferNext", + desc = "Go to next buffer", + mode = "n", + }, + { "bp", "BufferPick", desc = "Pick a buffer", mode = "n" }, + { + "bx", + "BufferCloseAllButPinned", + desc = "Delete all buffers", + mode = "n", + }, + { "c", group = "code", mode = "n" }, + { "ca", ":lua vim.lsp.buf.code_action()", desc = "Code actions", mode = "n" }, + { "cd", ":lua require'telescope.builtin'.diagnostics{}", desc = "Show diagnostics", mode = "n" }, + { + "cf", + ":lua require'telescope.builtin'.builtin.lsp_references{}", + desc = "Show references", + mode = "n", + }, + { + "q", + "wq", + desc = "Close window and buffer", + mode = "n", + }, + { "f", group = "file", mode = "n" }, + { + "fn", + "enew", + desc = "Create a new file", + mode = "n", + }, + { "fr", "Telescope oldfiles", desc = "Open Recent File", mode = "n" }, + { + "fs", + "w", + desc = "Save currently opened file", + mode = "n", + }, + { "g", group = "git", mode = "n" }, + { + "gb", + "Gitsigns toggle_current_line_blame", + desc = "Toggle git line blame", + mode = "n", + }, + { "gg", "LazyGit", desc = "Opens lazygit", mode = "n" }, + { + "glo", + "GitLink!", + desc = "Open permalink in browser", + mode = "n", + }, + { "gly", "GitLink", desc = "Copy permalink", mode = "n" }, + { + "n", + "Oil --float", + desc = "Open file browser", + mode = "n", + }, + { "q", "qa!", desc = "Leave neovim", mode = "n" }, + { "s", group = "search", mode = "n" }, + { "sb", ":lua require'telescope.builtin'.buffers{}", desc = "Find buffer", mode = "n" }, + { "ss", "Telescope live_grep", desc = "Live Grep", mode = "n" }, + { + "sw", + "Telescope grep_string", + desc = "Search current word", + mode = "n", + }, + { "t", group = "diagnostics (lsp)", mode = "n" }, + { + "td", + "Telescope diagnostics", + desc = "Show LSP diagnostics", + mode = "n", + }, + { "ta", "TodoQuickFix", desc = "Show all todo comments", mode = "n" }, + { "tt", "TodoTelescope", desc = "Show all todo comments (Telescope)", mode = "n" }, + { "w", group = "window", mode = "n" }, + { + "w+", + ":vertical resize +4", + desc = "Increase window size", + mode = "n", + }, + { + "w-", + ":vertical resize -4", + desc = "Decrease window size", + mode = "n", + }, + { + "wd", + "q", + desc = "Close active window", + mode = "n", + }, + { + "wh", + "h", + desc = "Move to window on left", + mode = "n", + }, + { + "wj", + "j", + desc = "Move to window on bottom", + mode = "n", + }, + { + "wk", + "k", + desc = "Move to window on top", + mode = "n", + }, + { + "wl", + "l", + desc = "Move to window on right", + mode = "n", + }, + { + "ws", + "sp", + desc = "Split windows horizontally", + mode = "n", + }, + { + "wv", + "vsp", + desc = "Split windows vertically", + mode = "n", + }, + { "x", group = "config", mode = "n" }, + { + "xn", + "set number relativenumber", + desc = "Show relative numbers", + mode = "n", + }, + { "xr", "source $MYVIMRC", desc = "Reload config", mode = "n" }, + { "do", "DiffviewOpen", desc = "Open diff view", mode = "n" }, + { "dh", "DiffviewFileHistory", desc = "Open file history diff", mode = "n" }, + }, +} diff --git a/home/modules/nvim/config/lua/plugins/zen-mode.lua b/home/modules/nvim/config/lua/plugins/zen-mode.lua new file mode 100644 index 0000000..a6ff8e2 --- /dev/null +++ b/home/modules/nvim/config/lua/plugins/zen-mode.lua @@ -0,0 +1,4 @@ +return { + "folke/zen-mode.nvim", + opts = {}, +} diff --git a/home/modules/nvim/config/stylua.toml b/home/modules/nvim/config/stylua.toml new file mode 100644 index 0000000..079f9f5 --- /dev/null +++ b/home/modules/nvim/config/stylua.toml @@ -0,0 +1,9 @@ +column_width = 120 +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferDouble" +call_parentheses = "Always" +collapse_simple_statement = "Never" + +[sort_requires] +enabled = false diff --git a/home/modules/nvim/default.nix b/home/modules/nvim/default.nix new file mode 100644 index 0000000..676eafa --- /dev/null +++ b/home/modules/nvim/default.nix @@ -0,0 +1,5 @@ +{ + home.file.".config/nvim" = { + source = ./config; + }; +}