diff --git a/home/neovim/config/init.lua b/home/neovim/config/init.lua new file mode 100644 index 00000000..e0a810fd --- /dev/null +++ b/home/neovim/config/init.lua @@ -0,0 +1,70 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = "," +vim.opt.termguicolors = true +vim.diagnostic.config { + virtual_text = true, + float = { border = "rounded" }, +} +require "ui.fillchars" + +-- bootstrap lazy.nvim +local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system { + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + } +end +vim.opt.rtp:prepend(lazypath) +require("lazy").setup { + spec = "plugins", + install = { colorscheme = { "tokyonight" } }, + ui = { + border = "rounded", + icons = { lazy = " " }, + }, + diff = { cmd = "diffview.nvim" }, + checker = { enabled = false }, + performance = { + rtp = { + disabled_plugins = { + "gzip", + "matchit", + "matchparen", + "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +} + +-- Set vim options +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.listchars = { lead = ".", trail = ".", tab = ">-" } +vim.opt.list = true +vim.opt.splitbelow = true +vim.opt.splitright = true +vim.opt.foldlevelstart = 99 +vim.g.loaded_perl_provider = 0 +vim.notify = require "notify" +require "dressing" + +-- Common keymaps +vim.keymap.set("i", "jk", "") +vim.keymap.set("n", "l", "Lazy") + +-- GUI settings +if vim.g.neovide then require "ui.neovide" end + +-- Colorscheme +vim.cmd [[colorscheme tokyonight]] diff --git a/home/neovim/config/lua/plugins/alpha.lua b/home/neovim/config/lua/plugins/alpha.lua new file mode 100644 index 00000000..e6aeee0c --- /dev/null +++ b/home/neovim/config/lua/plugins/alpha.lua @@ -0,0 +1,61 @@ +return { + "goolord/alpha-nvim", + event = "VimEnter", + opts = function() + local dashboard = require "alpha.themes.dashboard" + local logo = [[ + ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z + ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z + ██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z + ██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z + ███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ + ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ + ]] + + dashboard.section.header.val = vim.split(logo, "\n") + dashboard.section.buttons.val = { + dashboard.button("t", "󰝖 Tasks", 'lua require("taskwarrior_nvim").browser({"ready"}) '), + dashboard.button("f", " Find file", "Telescope find_files "), + dashboard.button("r", " Recent files", "Telescope oldfiles "), + dashboard.button("o", " File browser", "Oil "), + dashboard.button("p", "󱞁 Personal notes", "Neorg workspace personal"), + dashboard.button("w", "󱞂 Work notes", "Neorg workspace work"), + dashboard.button("g", "󰊢 Git status", "Neogit "), + dashboard.button("c", " Config", "e $HOME/.config/home-manager/flake.nix "), + dashboard.button("l", "󰒲 Lazy", "Lazy"), + dashboard.button("h", " Help", "Telescope help_tags "), + dashboard.button("q", " Quit", "qa"), + } + for _, button in ipairs(dashboard.section.buttons.val) do + button.opts.hl = "AlphaButtons" + button.opts.hl_shortcut = "AlphaShortcut" + end + dashboard.section.header.opts.hl = "AlphaHeader" + dashboard.section.buttons.opts.hl = "AlphaButtons" + dashboard.section.footer.opts.hl = "AlphaFooter" + dashboard.opts.layout[1].val = 8 + return dashboard + end, + config = function(_, dashboard) + -- close Lazy and re-open when the dashboard is ready + if vim.o.filetype == "lazy" then + vim.cmd.close() + vim.api.nvim_create_autocmd("User", { + pattern = "AlphaReady", + callback = function() require("lazy").show() end, + }) + end + + require("alpha").setup(dashboard.opts) + + vim.api.nvim_create_autocmd("User", { + pattern = "LazyVimStarted", + callback = function() + local stats = require("lazy").stats() + local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) + dashboard.section.footer.val = "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms" + pcall(vim.cmd.AlphaRedraw) + end, + }) + end, +} diff --git a/home/neovim/config/lua/plugins/barbar.lua b/home/neovim/config/lua/plugins/barbar.lua new file mode 100644 index 00000000..ddd0803f --- /dev/null +++ b/home/neovim/config/lua/plugins/barbar.lua @@ -0,0 +1,44 @@ +return { + "romgrk/barbar.nvim", + version = "^1.0.0", -- optional: only update when a new 1.x version is released + dependencies = { "lewis6991/gitsigns.nvim", "nvim-tree/nvim-web-devicons" }, + event = { "BufReadPre", "BufNewFile" }, + init = function() + vim.g.barbar_auto_setup = false + vim.keymap.set("n", "", "BufferPrevious", { noremap = true, silent = true }) + vim.keymap.set("n", "", "BufferNext", { noremap = true, silent = true }) + vim.keymap.set("n", "", "BufferMovePrevious", { noremap = true, silent = true }) + vim.keymap.set("n", ">", "BufferMoveNext", { noremap = true, silent = true }) + vim.keymap.set("n", "", "BufferPin", { noremap = true, silent = true }) + vim.keymap.set("n", "", "BufferClose", { noremap = true, silent = true }) + vim.keymap.set("n", "", "BufferCloseAllButCurrentOrPinned", { noremap = true, silent = true }) + vim.keymap.set("n", "", "BufferPick", { noremap = true, silent = true }) + vim.keymap.set("n", "bb", "BufferOrderByBufferNumber", { noremap = true, silent = true }) + vim.keymap.set("n", "bd", "BufferOrderByDirectory", { noremap = true, silent = true }) + vim.keymap.set("n", "bl", "BufferOrderByLanguage", { noremap = true, silent = true }) + vim.keymap.set("n", "bw", "BufferOrderByWindowNumber", { noremap = true, silent = true }) + end, + config = true, + opts = { + animation = true, + auto_hide = false, + tabpages = true, + hide = { extensions = true }, + modified = { button = "●" }, + pinned = { button = "車", filename = true, separator = { right = "" } }, + icons = { + separator = { left = "", right = "|" }, + button = "", + diagnostics = { + [vim.diagnostic.severity.ERROR] = { enabled = true, icon = require("ui.lsp_icons").Error }, + [vim.diagnostic.severity.WARN] = { enabled = true, icon = require("ui.lsp_icons").Warn }, + [vim.diagnostic.severity.INFO] = { enabled = true, icon = require("ui.lsp_icons").Hint }, + [vim.diagnostic.severity.HINT] = { enabled = true, icon = require("ui.lsp_icons").Info }, + }, + filetype = { + custom_colors = false, + enabled = true, + }, + }, + }, +} diff --git a/home/neovim/config/lua/plugins/barbecue.lua b/home/neovim/config/lua/plugins/barbecue.lua new file mode 100644 index 00000000..65083fec --- /dev/null +++ b/home/neovim/config/lua/plugins/barbecue.lua @@ -0,0 +1,15 @@ +return { + "utilyre/barbecue.nvim", + name = "barbecue", + version = "*", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "SmiteshP/nvim-navic", + "nvim-tree/nvim-web-devicons", + -- "catppuccin", + "folke/tokyonight.nvim", + }, + opts = { + theme = "tokyonight", + }, +} diff --git a/home/neovim/config/lua/plugins/comment.lua b/home/neovim/config/lua/plugins/comment.lua new file mode 100644 index 00000000..58100fc8 --- /dev/null +++ b/home/neovim/config/lua/plugins/comment.lua @@ -0,0 +1,7 @@ +return { + "numToStr/Comment.nvim", + dependencites = { "nvim-treesitter" }, + keys = { "gc", "gb" }, + config = true, + opts = { ignore = "^$" }, +} diff --git a/home/neovim/config/lua/plugins/diffview.lua b/home/neovim/config/lua/plugins/diffview.lua new file mode 100644 index 00000000..7e9ea049 --- /dev/null +++ b/home/neovim/config/lua/plugins/diffview.lua @@ -0,0 +1,15 @@ +return { + "sindrets/diffview.nvim", + dependencies = { "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons" }, + cmd = { + "DiffviewFileHistory", + "DiffviewOpen", + }, + config = true, + opts = { + enhanced_diff_hl = true, + file_panel = { + listing_style = "list", + }, + }, +} diff --git a/home/neovim/config/lua/plugins/direnv.lua b/home/neovim/config/lua/plugins/direnv.lua new file mode 100644 index 00000000..b9dc6af2 --- /dev/null +++ b/home/neovim/config/lua/plugins/direnv.lua @@ -0,0 +1,10 @@ +return { + "https://github.com/direnv/direnv.vim.git", + cond = function() return vim.fn.executable("direnv") == 1 end, + name = "direnv.vim", + event = { "DirChangedPre" }, + config = function() + vim.g.direnv_auto = 1 + vim.g.direnv_silent_load = 1 + end, +} diff --git a/home/neovim/config/lua/plugins/dressing.lua b/home/neovim/config/lua/plugins/dressing.lua new file mode 100644 index 00000000..a9861220 --- /dev/null +++ b/home/neovim/config/lua/plugins/dressing.lua @@ -0,0 +1,5 @@ +return { + "stevearc/dressing.nvim", + lazy = true, + config = true, +} diff --git a/home/neovim/config/lua/plugins/edgy.lua b/home/neovim/config/lua/plugins/edgy.lua new file mode 100644 index 00000000..f8b39f0e --- /dev/null +++ b/home/neovim/config/lua/plugins/edgy.lua @@ -0,0 +1,56 @@ +return { + "folke/edgy.nvim", + enabled = false, + event = "VeryLazy", + opts = { + bottom = { + -- toggleterm / lazyterm at the bottom with a height of 40% of the screen + { ft = "toggleterm", size = { height = 0.4 } }, + { + ft = "lazyterm", + title = "LazyTerm", + size = { height = 0.4 }, + filter = function(buf) return not vim.b[buf].lazyterm_cmd end, + }, + "Trouble", + { ft = "qf", title = "QuickFix" }, + { + ft = "help", + size = { height = 20 }, + -- only show help buffers + filter = function(buf) return vim.bo[buf].buftype == "help" end, + }, + { ft = "spectre_panel", size = { height = 0.4 } }, + }, + left = { + -- Neo-tree filesystem always takes half the screen height + { + title = "Neo-Tree", + ft = "neo-tree", + filter = function(buf) return vim.b[buf].neo_tree_source == "filesystem" end, + size = { height = 0.5 }, + }, + { + title = "Neo-Tree Git", + ft = "neo-tree", + filter = function(buf) return vim.b[buf].neo_tree_source == "git_status" end, + pinned = true, + open = "Neotree position=right git_status", + }, + { + title = "Neo-Tree Buffers", + ft = "neo-tree", + filter = function(buf) return vim.b[buf].neo_tree_source == "buffers" end, + pinned = true, + open = "Neotree position=top buffers", + }, + { + ft = "Outline", + pinned = true, + open = "SymbolsOutline", + }, + -- any other neo-tree windows + "neo-tree", + }, + }, +} diff --git a/home/neovim/config/lua/plugins/fidget.lua b/home/neovim/config/lua/plugins/fidget.lua new file mode 100644 index 00000000..19834c2c --- /dev/null +++ b/home/neovim/config/lua/plugins/fidget.lua @@ -0,0 +1,19 @@ +local opts = { + text = { + spinner = "dots", + done = "", + commenced = "", + completed = "", + }, + window = { + blend = 0, + border = "rounded", + }, +} +if vim.g.neovide then opts.window.blend = 50 end + +return { + "j-hui/fidget.nvim", + tag = "legacy", + opts = opts, +} diff --git a/home/neovim/config/lua/plugins/gitsigns.lua b/home/neovim/config/lua/plugins/gitsigns.lua new file mode 100644 index 00000000..e25d158d --- /dev/null +++ b/home/neovim/config/lua/plugins/gitsigns.lua @@ -0,0 +1,50 @@ +return { + "lewis6991/gitsigns.nvim", + event = { "BufReadPre", "BufNewFile" }, + config = true, + opts = { + signcolumn = true, + numhl = true, + linehl = false, + current_line_blame = true, + word_diff = false, + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map("n", "]c", function() + if vim.wo.diff then return "]c" end + vim.schedule(function() gs.next_hunk() end) + return "" + end, { expr = true }) + + map("n", "[c", function() + if vim.wo.diff then return "[c" end + vim.schedule(function() gs.prev_hunk() end) + return "" + end, { expr = true }) + + -- Actions + map({ "n", "v" }, "hs", ":Gitsigns stage_hunk") + map({ "n", "v" }, "hr", ":Gitsigns reset_hunk") + map("n", "hS", gs.stage_buffer) + map("n", "hu", gs.undo_stage_hunk) + map("n", "hR", gs.reset_buffer) + map("n", "hp", gs.preview_hunk) + map("n", "hb", function() gs.blame_line { full = true } end) + map("n", "tb", gs.toggle_current_line_blame) + map("n", "hd", gs.diffthis) + map("n", "hD", function() gs.diffthis "~" end) + map("n", "td", gs.toggle_deleted) + + -- Text object + map({ "o", "x" }, "ih", ":Gitsigns select_hunk") + end, + }, +} diff --git a/home/neovim/config/lua/plugins/hop.lua b/home/neovim/config/lua/plugins/hop.lua new file mode 100644 index 00000000..daf94913 --- /dev/null +++ b/home/neovim/config/lua/plugins/hop.lua @@ -0,0 +1,9 @@ +return { + "phaazon/hop.nvim", + cmd = { "HopWord", "HopLine" }, + init = function() + vim.keymap.set("n", "hw", "HopWord") + vim.keymap.set("n", "hl", "HopLine") + end, + config = true, +} diff --git a/home/neovim/config/lua/plugins/indent_blankline.lua b/home/neovim/config/lua/plugins/indent_blankline.lua new file mode 100644 index 00000000..6564e43b --- /dev/null +++ b/home/neovim/config/lua/plugins/indent_blankline.lua @@ -0,0 +1,10 @@ +return { + "lukas-reineke/indent-blankline.nvim", + dependencies = {"nvim-treesitter"}, + event = { "BufReadPre", "BufNewFile" }, + config = true, + opts = { + show_current_context = true, + show_current_context_start = false, + }, +} diff --git a/home/neovim/config/lua/plugins/init.lua b/home/neovim/config/lua/plugins/init.lua new file mode 100644 index 00000000..83c7a0a7 --- /dev/null +++ b/home/neovim/config/lua/plugins/init.lua @@ -0,0 +1,3 @@ +return { + { "folke/lazy.nvim", cmd = "Lazy" }, +} diff --git a/home/neovim/config/lua/plugins/lspconfig.lua b/home/neovim/config/lua/plugins/lspconfig.lua new file mode 100644 index 00000000..b43986e6 --- /dev/null +++ b/home/neovim/config/lua/plugins/lspconfig.lua @@ -0,0 +1,98 @@ +local on_attach = function(client, bufnr) + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local bufopts = { noremap = true, silent = true, buffer = bufnr } + vim.keymap.set("n", "gd", "TroubleToggle lsp_definitions") + vim.keymap.set("n", "gr", "TroubleToggle lsp_references") + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts) + vim.keymap.set("n", "K", function() vim.lsp.buf.hover { popup_opts = { border = "rounded" } } end, bufopts) + vim.keymap.set("n", "D", "TroubleToggle lsp_type_definitions") + vim.keymap.set("n", "rn", vim.lsp.buf.rename, bufopts) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, bufopts) + vim.keymap.set( + "n", + "i", + function() vim.lsp.buf.format { bufnr = bufnr, timeout_ms = 2000, async = true } end, + bufopts + ) + + -- specific client tweaks + if client.name ~= "null-ls" then client.server_capabilities.documentFormattingProvider = false end + if client.name == "ruff_lsp" then client.server_capabilities.hoverProvider = false end + + -- Attach navic and navbuddy if applicable + if client.server_capabilities.documentSymbolProvider then + require("nvim-navic").attach(client, bufnr) + require("nvim-navbuddy").attach(client, bufnr) + end +end + +local config = function() + require("neodev").setup() + + -- Mappings. + -- See `:help vim.diagnostic.*` for documentation on any of the below functions + local opts = { noremap = true, silent = true } + vim.keymap.set("n", "e", vim.diagnostic.open_float, opts) + vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) + vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) + vim.keymap.set("n", "q", vim.diagnostic.setloclist, opts) + + local signs = require "ui.lsp_icons" + for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) + end + + local lsp_config = { + on_attach = on_attach, + flags = { debounce_text_changes = 150 }, + capabilities = require("cmp_nvim_lsp").default_capabilities(), + } + local lsp = require "lspconfig" + if vim.fn.executable "pyright" == 1 then + lsp["pyright"].setup(lsp_config) + elseif vim.fn.executable "pyslp" == 1 then + lsp["pylsp"].setup(lsp_config) + end + if vim.fn.executable "ruff-lsp" == 1 then lsp["ruff_lsp"].setup(lsp_config) end + if vim.fn.executable "lua-language-server" == 1 then + lsp["lua_ls"].setup { + on_attach = lsp_config.on_attach, + flags = lsp_config.flags, + capabilities = lsp_config.capabilities, + settings = { Lua = { workspace = { checkThirdParty = false } } }, + } + end + if vim.fn.executable "nil" == 1 then lsp["nil_ls"].setup(lsp_config) end + if vim.fn.executable "fortls" == 1 then lsp["fortls"].setup(lsp_config) end + if vim.fn.executable "yaml-language-server" == 1 then lsp["yamlls"].setup(lsp_config) end + if vim.fn.executable "vim-language-server" == 1 then lsp["vimls"].setup(lsp_config) end + if vim.fn.executable "bash-language-server" == 1 then lsp["bashls"].setup(lsp_config) end + + local builtins = require "null-ls.builtins" + require("null-ls").setup { + sources = { + builtins.code_actions.gitsigns, + builtins.formatting.alejandra, + builtins.formatting.beautysh, + builtins.formatting.black, + builtins.formatting.fixjson, + builtins.formatting.isort, + builtins.formatting.mdformat, + builtins.formatting.shellharden, + builtins.formatting.stylua, + builtins.hover.dictionary, + }, + on_attach = lsp_config.on_attach, + flags = lsp_config.flags, + capabilities = lsp_config.capabilities, + } +end + +return { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { "cmp-nvim-lsp", "folke/trouble.nvim", "folke/neodev.nvim", "jose-elias-alvarez/null-ls.nvim" }, + config = config, +} diff --git a/home/neovim/config/lua/plugins/lualine.lua b/home/neovim/config/lua/plugins/lualine.lua new file mode 100644 index 00000000..072687cd --- /dev/null +++ b/home/neovim/config/lua/plugins/lualine.lua @@ -0,0 +1,37 @@ +return { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons", "folke/tokyonight.nvim" }, + event = { "VeryLazy" }, + config = true, + opts = function() + return { + options = { + theme = "tokyonight", + component_separators = "|", + section_separators = { left = "", right = "" }, + globalstatus = true, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "filename", { "branch", icon = "󰊢" }, "diff" }, + lualine_c = { + { + "diagnostics", + symbols = { + error = require("ui.lsp_icons").Error, + warn = require("ui.lsp_icons").Warn, + info = require("ui.lsp_icons").Info, + hint = require("ui.lsp_icons").Hint, + }, + }, + }, + lualine_x = { "filetype", "fileformat", "encoding" }, + lualine_y = { "progress" }, + lualine_z = { "selectioncount", "location" }, + }, + tabline = {}, + winbar = {}, + extensions = { "aerial", "fzf", "lazy", "neo-tree", "toggleterm", "trouble" }, + } + end, +} diff --git a/home/neovim/config/lua/plugins/luasnip.lua b/home/neovim/config/lua/plugins/luasnip.lua new file mode 100644 index 00000000..2830d483 --- /dev/null +++ b/home/neovim/config/lua/plugins/luasnip.lua @@ -0,0 +1,9 @@ +return { + "L3MON4D3/LuaSnip", + lazy = true, + dependencies = { + "rafamadriz/friendly-snippets", + config = function() require("luasnip.loaders.from_vscode").lazy_load() end, + }, + -- build = "make install_jsregexp", +} diff --git a/home/neovim/config/lua/plugins/nabla.lua b/home/neovim/config/lua/plugins/nabla.lua new file mode 100644 index 00000000..1cd475a4 --- /dev/null +++ b/home/neovim/config/lua/plugins/nabla.lua @@ -0,0 +1,8 @@ +return { + "jbyuki/nabla.nvim", + lazy = true, + init = function() + vim.keymap.set("n", "p", "lua require('nabla').popup()") + vim.keymap.set("n", "m", "lua require('nabla').toggle_virt()") + end, +} diff --git a/home/neovim/config/lua/plugins/neogit.lua b/home/neovim/config/lua/plugins/neogit.lua new file mode 100644 index 00000000..6c569867 --- /dev/null +++ b/home/neovim/config/lua/plugins/neogit.lua @@ -0,0 +1,15 @@ +return { + "NeogitOrg/neogit", + dependencies = { + "nvim-lua/plenary.nvim", + "sindrets/diffview.nvim", + }, + cmd = "Neogit", + init = function() vim.keymap.set("n", "g", "Neogit") end, + config = true, + opts = { + disable_commit_confirmation = true, + disable_builtin_notifications = true, + integrations = { diffview = true }, + }, +} diff --git a/home/neovim/config/lua/plugins/notify.lua b/home/neovim/config/lua/plugins/notify.lua new file mode 100644 index 00000000..a4237a29 --- /dev/null +++ b/home/neovim/config/lua/plugins/notify.lua @@ -0,0 +1,10 @@ +return { + "rcarriga/nvim-notify", + lazy = true, + config = true, + opts = { + background_colour = "#000000", + fps = 60, + render = "default", + }, +} diff --git a/home/neovim/config/lua/plugins/nvim_cmp.lua b/home/neovim/config/lua/plugins/nvim_cmp.lua new file mode 100644 index 00000000..7d97a7b8 --- /dev/null +++ b/home/neovim/config/lua/plugins/nvim_cmp.lua @@ -0,0 +1,69 @@ +local config = function() + local cmp = require "cmp" + local luasnip = require "luasnip" + local cmp_autopairs = require "nvim-autopairs.completion.cmp" + + cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = cmp.mapping.preset.insert { + [""] = cmp.mapping.scroll_docs(-4), -- Up + [""] = cmp.mapping.scroll_docs(4), -- Down + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }, + sources = { { name = "nvim_lsp" }, { name = "luasnip" }, { name = "neorg" } }, + } + + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) +end + +return { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + { + "windwp/nvim-autopairs", + cond = not vim.g.vscode, + lazy = true, + dependencies = { + "nvim-treesitter/nvim-treesitter", + "hrsh7th/nvim-cmp", + }, + config = true, + opts = { + disable_in_macro = true, + disable_in_visualblock = true, + check_ts = true, + }, + }, + "saadparwaiz1/cmp_luasnip", + "L3MON4D3/LuaSnip", + }, + config = config, +} diff --git a/home/neovim/config/lua/plugins/nvim_navbuddy.lua b/home/neovim/config/lua/plugins/nvim_navbuddy.lua new file mode 100644 index 00000000..d2ec9a28 --- /dev/null +++ b/home/neovim/config/lua/plugins/nvim_navbuddy.lua @@ -0,0 +1,33 @@ +return { + "SmiteshP/nvim-navbuddy", + dependencies = { + "SmiteshP/nvim-navic", + "MunifTanjim/nui.nvim", + "neovim/nvim-lspconfig", + "numToStr/Comment.nvim", + "nvim-telescope/telescope.nvim", + }, + cmd = { "Navbuddy" }, + init = function() vim.keymap.set("n", "na", "Navbuddy") end, + config = true, + opts = { + icons = require "ui.navic_icons", + window = { + border = "rounded", + size = "80%", + sections = { + left = { border = "rounded" }, + mid = { border = "rounded" }, + right = { border = "rounded", preview = "leaf" }, + }, + }, + node_markers = { + enabled = true, + icons = { + leaf = "󰅀 ", + leaf_selected = "󰄼 ", + branch = "󰅂 ", + }, + }, + }, +} diff --git a/home/neovim/config/lua/plugins/nvim_navic.lua b/home/neovim/config/lua/plugins/nvim_navic.lua new file mode 100644 index 00000000..80e82267 --- /dev/null +++ b/home/neovim/config/lua/plugins/nvim_navic.lua @@ -0,0 +1,11 @@ +return { + "SmiteshP/nvim-navic", + dependencies = "neovim/nvim-lspconfig", + lazy = true, + config = true, + opts = { + safe_output = true, + click = true, + icons = require "ui.navic_icons", + }, +} diff --git a/home/neovim/config/lua/plugins/nvim_neorg.lua b/home/neovim/config/lua/plugins/nvim_neorg.lua new file mode 100644 index 00000000..20727b5e --- /dev/null +++ b/home/neovim/config/lua/plugins/nvim_neorg.lua @@ -0,0 +1,46 @@ +return { + "nvim-neorg/neorg", + cond = function() return vim.fn.executable "nix" == 1 end, + build = ":Neorg sync-parsers", + ft = "norg", + cmd = "Neorg", + lazy = true, + dependencies = { "plenary.nvim", "nvim-treesitter", "nvim-cmp", "nabla.nvim" }, + init = function() + vim.api.nvim_create_autocmd({ "BufWritePre" }, { + pattern = { "*.norg" }, + command = "Neorg update-metadata", + }) + vim.api.nvim_create_autocmd({ "BufReadPre", "BufNewFile" }, { + pattern = { "*.norg" }, + command = "setlocal spell spelllang=en_gb", + }) + vim.api.nvim_create_autocmd({ "BufReadPre", "BufNewFile" }, { + pattern = { "*.norg" }, + command = "setlocal textwidth=79", + }) + vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, { + pattern = { "*.norg" }, + command = "lua require('nabla').enable_virt()", + }) + vim.keymap.set("n", "wp", "Neorg workspace personal ") + vim.keymap.set("n", "ww", "Neorg workspace work ") + vim.keymap.set("n", "wr", "Neorg return ") + vim.keymap.set("n", "jo", "Neorg journal today ") + vim.keymap.set("n", "jc", "Neorg journal custom ") + vim.keymap.set("n", "jn", "Neorg journal tomorrow ") + vim.keymap.set("n", "jp", "Neorg journal yesterday ") + vim.keymap.set("n", "jt", "Neorg journal template ") + end, + opts = { + load = { + ["core.defaults"] = {}, + ["core.concealer"] = { config = { icon_preset = "diamond" } }, + ["core.dirman"] = { config = { workspaces = { personal = "~/notes/personal", work = "~/notes/work" } } }, + ["core.completion"] = { config = { engine = "nvim-cmp" } }, + ["core.journal"] = {}, + ["core.presenter"] = { config = { zen_mode = "zen-mode" } }, + ["core.ui.calendar"] = {}, + }, + }, +} diff --git a/home/neovim/config/lua/plugins/nvim_neotest.lua b/home/neovim/config/lua/plugins/nvim_neotest.lua new file mode 100644 index 00000000..e0eb75eb --- /dev/null +++ b/home/neovim/config/lua/plugins/nvim_neotest.lua @@ -0,0 +1,12 @@ +return { + "nvim-neotest/neotest", + lazy = true, + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + -- "antoinemadec/FixCursorHold.nvim", + "nvim-neotest/neotest-python", + }, + config = true, + opts = function() return { adapters = { require "neotest-python" } } end, +} diff --git a/home/neovim/config/lua/plugins/oil.lua b/home/neovim/config/lua/plugins/oil.lua new file mode 100644 index 00000000..7912150a --- /dev/null +++ b/home/neovim/config/lua/plugins/oil.lua @@ -0,0 +1,17 @@ +return { + "stevearc/oil.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + cmd = "Oil", + init = function() + vim.keymap.set("n", "o", "Oil") + if vim.fn.argc() == 1 then + local stat = vim.loop.fs_stat(vim.fn.argv(0)) + if stat and stat.type == "directory" then require "oil" end + end + end, + config = true, + opts = { + columns = { "icon", "permissions" }, + view_options = { show_hidden = true }, + }, +} diff --git a/home/neovim/config/lua/plugins/project.lua b/home/neovim/config/lua/plugins/project.lua new file mode 100644 index 00000000..6efff014 --- /dev/null +++ b/home/neovim/config/lua/plugins/project.lua @@ -0,0 +1,13 @@ +return { + "ahmedkhalf/project.nvim", + name = "project_nvim", + event = { "BufReadPre", "BufNewFile" }, + config = true, + opts = { + detection_methods = { "lsp", "pattern" }, + patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json", "index.norg" }, + ignore_lsp = { "null-ls" }, + show_hidden = true, + silent_chdir = true, + }, +} diff --git a/home/neovim/config/lua/plugins/spectre.lua b/home/neovim/config/lua/plugins/spectre.lua new file mode 100644 index 00000000..d7993bd9 --- /dev/null +++ b/home/neovim/config/lua/plugins/spectre.lua @@ -0,0 +1,27 @@ +return { + "nvim-pack/nvim-spectre", + cmd = "Spectre", + dependencies = { "nvim-lua/plenary.nvim" }, + init = function() + vim.keymap.set("n", "so", 'lua require("spectre").open()', { desc = "Open Spectre" }) + vim.keymap.set( + "n", + "sw", + 'lua require("spectre").open_visual({select_word=true})', + { desc = "Search current word" } + ) + vim.keymap.set( + "v", + "sw", + 'lua require("spectre").open_visual()', + { desc = "Search current word" } + ) + vim.keymap.set( + "n", + "sp", + 'lua require("spectre").open_file_search({select_word=true})', + { desc = "Search on current file" } + ) + end, + config = true, +} diff --git a/home/neovim/config/lua/plugins/symbols-outline.lua b/home/neovim/config/lua/plugins/symbols-outline.lua new file mode 100644 index 00000000..30c46345 --- /dev/null +++ b/home/neovim/config/lua/plugins/symbols-outline.lua @@ -0,0 +1,7 @@ +return { + "simrat39/symbols-outline.nvim", + cmd = "SymbolsOutline", + dependencies = { "neovim/nvim-lspconfig" }, + init = function() vim.keymap.set("n", "no", "SymbolsOutline ") end, + config = true, +} diff --git a/home/neovim/config/lua/plugins/taskwarrior.lua b/home/neovim/config/lua/plugins/taskwarrior.lua new file mode 100644 index 00000000..cdaf0dc2 --- /dev/null +++ b/home/neovim/config/lua/plugins/taskwarrior.lua @@ -0,0 +1,18 @@ +local browser = function(report) + -- Return function to call taskwarrior browser with given report + return function() require("taskwarrior_nvim").browser { report } end +end + +return { + "ColonQExclamationMark/taskwarrior.nvim", + branch = "1-Issues-initializing", -- Temp until PR is merged upstream + dependencies = { "nvim-telescope/telescope.nvim" }, + cmd = "Task", + init = function() + vim.keymap.set("n", "tr", browser "ready") + vim.keymap.set("n", "ta", browser "active") + vim.keymap.set("n", "tn", browser "next") + end, + opts = {}, + config = function() require("taskwarrior_nvim").setup() end, +} diff --git a/home/neovim/config/lua/plugins/telescope.lua b/home/neovim/config/lua/plugins/telescope.lua new file mode 100644 index 00000000..97388f3e --- /dev/null +++ b/home/neovim/config/lua/plugins/telescope.lua @@ -0,0 +1,45 @@ +return { + "nvim-telescope/telescope.nvim", + branch = "0.1.x", + dependencies = { + { + { "nvim-lua/plenary.nvim" }, + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + { "tsakirist/telescope-lazy.nvim", dependencies = { "folke/lazy.nvim" } }, + { "benfowler/telescope-luasnip.nvim", dependencies = { "L3MON4D3/LuaSnip" } }, + }, + }, + cmd = "Telescope", + init = function() + vim.keymap.set("n", "ff", "Telescope find_files") + vim.keymap.set("n", "fh", "Telescope help_tags") + vim.keymap.set("n", "fr", "Telescope oldfiles") + vim.keymap.set("n", "fg", "Telescope live_grep") + vim.keymap.set("n", "fs", "Telescope lsp_document_symbols") + vim.keymap.set("n", "ft", "Telescope treesitter") + vim.keymap.set("n", "fz", "Telescope current_buffer_fuzzy_find") + vim.keymap.set("n", "fl", "Telescope lazy") + end, + config = function() + local trouble = require "trouble.providers.telescope" + require("telescope").setup { + defaults = { + layout_strategy = "flex", + mappings = { + i = { [""] = trouble.open_with_trouble }, + n = { [""] = trouble.open_with_trouble }, + }, + winblend = vim.o.winblend, + }, + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + }, + }, + } + require("telescope").load_extension "fzf" + require("telescope").load_extension "lazy" + end, +} diff --git a/home/neovim/config/lua/plugins/toggleterm.lua b/home/neovim/config/lua/plugins/toggleterm.lua new file mode 100644 index 00000000..4b5d6268 --- /dev/null +++ b/home/neovim/config/lua/plugins/toggleterm.lua @@ -0,0 +1,7 @@ +return { + "akinsho/toggleterm.nvim", + version = "*", + cmd = { "ToggleTerm" }, + init = function() vim.keymap.set("n", "tt", "ToggleTerm") end, + opts = { direction = "horizontal" }, +} diff --git a/home/neovim/config/lua/plugins/tokyonight.lua b/home/neovim/config/lua/plugins/tokyonight.lua new file mode 100644 index 00000000..349b74ce --- /dev/null +++ b/home/neovim/config/lua/plugins/tokyonight.lua @@ -0,0 +1,11 @@ +return { + "folke/tokyonight.nvim", + lazy = true, + config = true, + opts = { + style = "night", + transparent = not vim.g.neovide, + terminal_colors = true, + styles = { sidebars = "transparent", floats = "transparent" }, + }, +} diff --git a/home/neovim/config/lua/plugins/treesitter.lua b/home/neovim/config/lua/plugins/treesitter.lua new file mode 100644 index 00000000..1da9bc82 --- /dev/null +++ b/home/neovim/config/lua/plugins/treesitter.lua @@ -0,0 +1,60 @@ +local options = { + highlight = { + enable = true, + disable = { "fortran" }, + additional_vim_regex_highlighting = false, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "gnr", + scope_incremental = "gnc", + node_decremental = "gnm", + }, + }, + indent = { + enable = true, + }, + refactor = { + smart_rename = { + enable = true, + keymaps = { + smart_rename = "grr", + }, + }, + navigation = { + enable = true, + keymaps = { + goto_definition_lsp_fallback = "gnd", + }, + }, + }, +} + +if vim.fn.executable "nix" == 1 then + options.auto_install = true + options.ensure_installed = "all" +end + +return { + "nvim-treesitter/nvim-treesitter", + version = false, + build = ":TSUpdate", + cmd = { "TSUpdate", "TSInstall" }, + event = { "BufReadPre", "BufNewFile" }, + dependencies = "nvim-treesitter/nvim-treesitter-refactor", + config = function(_, opts) + if type(opts.ensure_installed) == "table" then + -- @type table + local added = {} + opts.ensure_installed = vim.tbl_filter(function(lang) + if added[lang] then return false end + added[lang] = true + return true + end, opts.ensure_installed) + end + require("nvim-treesitter.configs").setup(opts) + end, + opts = options, +} diff --git a/home/neovim/config/lua/plugins/trouble.lua b/home/neovim/config/lua/plugins/trouble.lua new file mode 100644 index 00000000..4ad041a4 --- /dev/null +++ b/home/neovim/config/lua/plugins/trouble.lua @@ -0,0 +1,15 @@ +return { + "folke/trouble.nvim", + dependencies = "nvim-tree/nvim-web-devicons", + cmd = "TroubleToggle", + init = function() vim.keymap.set("n", "xx", "TroubleToggle") end, + config = true, + opts = { + mode = "workspace_diagnostics", + auto_open = false, + auto_close = true, + auto_preview = true, + auto_jump = { "lsp_definitions" }, + use_diagnostic_signs = true, + }, +} diff --git a/home/neovim/config/lua/plugins/twilight.lua b/home/neovim/config/lua/plugins/twilight.lua new file mode 100644 index 00000000..2b317746 --- /dev/null +++ b/home/neovim/config/lua/plugins/twilight.lua @@ -0,0 +1,7 @@ +return { + "folke/twilight.nvim", + dependencies = { "nvim-treesitter" }, + cmd = "Twilight", + config = true, + opts = { context = 10, treesitter = true }, +} diff --git a/home/neovim/config/lua/plugins/which_key.lua b/home/neovim/config/lua/plugins/which_key.lua new file mode 100644 index 00000000..2f0fb2df --- /dev/null +++ b/home/neovim/config/lua/plugins/which_key.lua @@ -0,0 +1,9 @@ +return { + "folke/which-key.nvim", + keys = { "" }, + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + end, + config = true, +} diff --git a/home/neovim/config/lua/plugins/wilder.lua b/home/neovim/config/lua/plugins/wilder.lua new file mode 100644 index 00000000..7039329f --- /dev/null +++ b/home/neovim/config/lua/plugins/wilder.lua @@ -0,0 +1,42 @@ +return { + "gelguy/wilder.nvim", + dependencies = { + "romgrk/fzy-lua-native", + }, + config = function() + local wilder = require "wilder" + wilder.setup { modes = { "/", "?", ":" } } + -- Disable Python remote plugin + wilder.set_option("use_python_remote_plugin", 0) + wilder.set_option("pipeline", { + wilder.branch( + wilder.cmdline_pipeline { + fuzzy = 1, + fuzzy_filter = wilder.lua_fzy_filter(), + }, + wilder.vim_search_pipeline() + ), + }) + wilder.set_option( + "renderer", + wilder.renderer_mux { + [":"] = wilder.popupmenu_renderer(wilder.popupmenu_border_theme { + highlighter = wilder.lua_fzy_highlighter(), + left = { + " ", + wilder.popupmenu_devicons(), + }, + right = { + " ", + wilder.popupmenu_scrollbar(), + }, + border = "rounded", + min_width = "50%", + }), + ["/"] = wilder.wildmenu_renderer { + highlighter = wilder.lua_fzy_highlighter(), + }, + } + ) + end, +} diff --git a/home/neovim/config/lua/plugins/zen_mode.lua b/home/neovim/config/lua/plugins/zen_mode.lua new file mode 100644 index 00000000..2a0ae7ee --- /dev/null +++ b/home/neovim/config/lua/plugins/zen_mode.lua @@ -0,0 +1,36 @@ +return { + "folke/zen-mode.nvim", + dependencies = { "folke/twilight.nvim" }, + cmd = { "ZenMode" }, + init = function() vim.keymap.set("n", "z", "ZenMode") end, + config = true, + opts = { + window = { + width = 80, + options = { + signcolumn = "no", -- disable signcolumn + number = false, -- disable number column + relativenumber = false, -- disable relative numbers + cursorline = false, -- disable cursorline + cursorcolumn = false, -- disable cursor column + foldcolumn = "0", -- disable fold column + list = false, -- disable whitespace characters + }, + }, + plugins = { + options = { + enabled = true, + ruler = false, + showcmd = false, + }, + twilight = { enabled = true }, + gitsigns = { enabled = true }, + wezterm = { + enabled = false, + font = "+4", -- (10% increase per step) + }, + }, + on_open = function(win) vim.wo.scrolloff = 999 end, + on_close = function(win) vim.wo.scrolloff = -1 end, + }, +} diff --git a/home/neovim/config/lua/ui/fillchars.lua b/home/neovim/config/lua/ui/fillchars.lua new file mode 100644 index 00000000..61a2aa07 --- /dev/null +++ b/home/neovim/config/lua/ui/fillchars.lua @@ -0,0 +1,9 @@ +vim.opt.fillchars:append { + horiz = "━", + horizup = "┻", + horizdown = "┳", + vert = "┃", + vertleft = "┨", + vertright = "┣", + verthoriz = "╋", +} diff --git a/home/neovim/config/lua/ui/lsp_icons.lua b/home/neovim/config/lua/ui/lsp_icons.lua new file mode 100644 index 00000000..23e5dc1f --- /dev/null +++ b/home/neovim/config/lua/ui/lsp_icons.lua @@ -0,0 +1 @@ +return { Error = " ", Warn = " ", Info = " ", Hint = " " } diff --git a/home/neovim/config/lua/ui/navic_icons.lua b/home/neovim/config/lua/ui/navic_icons.lua new file mode 100644 index 00000000..cfb49089 --- /dev/null +++ b/home/neovim/config/lua/ui/navic_icons.lua @@ -0,0 +1,28 @@ +return { + File = " ", + Module = " ", + Namespace = " ", + Package = " ", + Class = " ", + Method = " ", + Property = " ", + Field = " ", + Constructor = " ", + Enum = " ", + Interface = " ", + Function = " ", + Variable = " ", + Constant = " ", + String = " ", + Number = " ", + Boolean = " ", + Array = " ", + Object = " ", + Key = " ", + Null = " ", + EnumMember = " ", + Struct = " ", + Event = " ", + Operator = " ", + TypeParameter = " ", +} diff --git a/home/neovim/config/lua/ui/neovide.lua b/home/neovim/config/lua/ui/neovide.lua new file mode 100644 index 00000000..ca57477b --- /dev/null +++ b/home/neovim/config/lua/ui/neovide.lua @@ -0,0 +1,14 @@ +vim.opt.winblend = 20 +vim.opt.pumblend = 20 + +vim.g.neovide_padding_top = 5 +vim.g.neovide_padding_bottom = 5 +vim.g.neovide_padding_left = 5 +vim.g.neovide_padding_right = 5 + +vim.g.neovide_transparency = 0.8 +vim.g.neovide_floating_blur_amount_x = 2.0 +vim.g.neovide_floating_blur_amount_y = 2.0 + +vim.g.neovide_hide_mouse_when_typing = false +vim.g.neovide_remember_window_size = false diff --git a/home/neovim/default.nix b/home/neovim/default.nix new file mode 100644 index 00000000..20df60d9 --- /dev/null +++ b/home/neovim/default.nix @@ -0,0 +1,48 @@ +{ pkgs, ... }: { + xdg.configFile.nvim = { + source = ./config; + recursive = true; + }; + programs.neovim = { + enable = true; + defaultEditor = true; + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + withNodeJs = true; + withRuby = true; + withPython3 = true; + extraPackages = with pkgs; [ + # Misc utils + curl + fzf + git + gnutar + gnumake + gnused + gcc + ripgrep + tree-sitter + + # Language servers + nil + lua-language-server + fortls + nodePackages.pyright + nodePackages.yaml-language-server + nodePackages.vim-language-server + nodePackages.bash-language-server + + # Null LSP formatters + alejandra + beautysh + black + nodePackages.fixjson + fprettify + isort + python3Packages.mdformat + shellharden + stylua + ]; + }; +}