all repos

init.lua @ 53feeb8

my nvim config
46 files changed, 733 insertions(+), 696 deletions(-)
migrate from package.nvim to lazy.nvim (#1)

* migration to lazy.nvim

* some refactoring

* run `stylua .`

* remove packar maps

* some more refactoring

* disable buildins w/ lazy.nvim

* fix: gitsigns keymaps

* reformat code

* feat(keymaps): add hotkey for opening the Lazy

* update plugins
Author: Smirnov Oleksandr ss2316544@gmail.com
Committed by: GitHub noreply@github.com
Committed at: 2023-02-01 18:44:10 +0200
Parent: 5df81c1
M README.md

@@ -8,8 +8,6 @@

```bash # Install nvim paru -S neovim-git -# Install packer.nvim -git clone https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim # (optiolan) backup your old config mv ~/.config/nvim ~/.config/nvim.old # clone my setup
M init.lua

@@ -1,9 +1,4 @@

-local ok, impatient = pcall(require, "impatient") -if ok and impatient ~= nil then - impatient.enable_profile() -end - require "core.options" -require "plugins" +require "core.lazy" require "core.keymaps" require "core.autocmd"
A lazy-lock.json

@@ -0,0 +1,46 @@

+{ + "Comment.nvim": { "branch": "master", "commit": "eab2c83a0207369900e92783f56990808082eac2" }, + "LuaSnip": { "branch": "master", "commit": "94f192cf5f0a1931b3035c2d8affdebec460968c" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "59224771f91b86d1de12570b4070fe4ad7cd1eeb" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "codeium.vim": { "branch": "main", "commit": "66c878f2481b4168a4c4124bf73bd58949e9af57" }, + "debugprint.nvim": { "branch": "main", "commit": "3a1a265e0adc3422aa2f00a8b49b436f913110ac" }, + "editorconfig.nvim": { "branch": "master", "commit": "5b9e303e1d6f7abfe616ce4cc8d3fffc554790bf" }, + "friendly-snippets": { "branch": "main", "commit": "a6f7a1609addb4e57daa6bedc300f77f8d225ab7" }, + "gitsigns.nvim": { "branch": "main", "commit": "0d4fe37ba5285171f3729da955955205f3fa945b" }, + "lazy.nvim": { "branch": "main", "commit": "3d2dcb2d5ef99106c5ff412da88c6f59a9f8a693" }, + "lsp-inlayhints.nvim": { "branch": "main", "commit": "84ca3abe8aaecbb5b30ad89e4701d4a9c821b72c" }, + "lualine.nvim": { "branch": "master", "commit": "0050b308552e45f7128f399886c86afefc3eb988" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "53f3a8bdcb77d4a95b082fd57e12173f353c6c3e" }, + "mason.nvim": { "branch": "main", "commit": "46400632ed629add5f56faf7b8748c656ff88602" }, + "neodev.nvim": { "branch": "main", "commit": "8fd21037453f4306f500e437c5cbdf6e8b6c2f99" }, + "neogit": { "branch": "master", "commit": "089d388876a535032ac6a3f80e19420f09e4ddda" }, + "neotest": { "branch": "master", "commit": "392808a91d6ee28d27cbfb93c9fd9781759b5d00" }, + "neotest-go": { "branch": "main", "commit": "981406c12bd3c77eb434211a1b85b964ab5bbdd5" }, + "neotest-plenary": { "branch": "master", "commit": "d49bfd9470f791e7c29149e75d56b6f925bb391b" }, + "null-ls.nvim": { "branch": "main", "commit": "c3e678110d5f31854c6575cf4bda3b82f3d4a884" }, + "nvim-autopairs": { "branch": "master", "commit": "5a3523ddb573804752de6c021c5cb82e267b79ca" }, + "nvim-cmp": { "branch": "main", "commit": "e7e2ef7031db8e0cfad7ad9916ec766ddd9dbb3b" }, + "nvim-dap": { "branch": "master", "commit": "0e376f00e7fac143e29e1017d2ac2cc3df13d185" }, + "nvim-dap-ui": { "branch": "master", "commit": "885e958ff9de30cfbc359259eccf28cc493ad46b" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "7f7f2af549e72a0b7bddc3b4f827beb027ea8ce3" }, + "nvim-lspconfig": { "branch": "master", "commit": "902d6aa31450d26e11bedcbef8af5b6fe2e1ffe8" }, + "nvim-tree.lua": { "branch": "master", "commit": "215b29bfad74518442621b9d0483a621483b066b" }, + "nvim-treesitter": { "branch": "master", "commit": "4cc201ecd9840562ed8822af607966e3303df228" }, + "nvim-treesitter-endwise": { "branch": "master", "commit": "0cf4601c330cf724769a2394df555a57d5fd3f34" }, + "nvim-ts-rainbow": { "branch": "master", "commit": "ef95c15a935f97c65a80e48e12fe72d49aacf9b9" }, + "nvim-web-devicons": { "branch": "master", "commit": "a421d183ef37dfa13f51a5805bed2381aebf9080" }, + "plenary.nvim": { "branch": "master", "commit": "9a0d3bf7b832818c042aaf30f692b081ddd58bd9" }, + "project.nvim": { "branch": "main", "commit": "685bc8e3890d2feb07ccf919522c97f7d33b94e4" }, + "schemastore.nvim": { "branch": "main", "commit": "d98828169af99624031d8535785a099cdf60d4c3" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "62ea5e58c7bbe191297b983a9e7e89420f581369" }, + "telescope.nvim": { "branch": "master", "commit": "203bf5609137600d73e8ed82703d6b0e320a5f36" }, + "todo-comments.nvim": { "branch": "main", "commit": "74c7d28cb50b0713c881ef69bcb6cdd77d8907d1" }, + "tokyonight.nvim": { "branch": "main", "commit": "affb21a81e6d7de073378eb86d02864c594104d9" }, + "undotree": { "branch": "master", "commit": "1a23ea84bd02c34f50d8e10a8b4bfc89597ffe4e" }, + "vim-illuminate": { "branch": "master", "commit": "d6ca7f77eeaf61b3e6ce9f0e5a978d606df44298" }, + "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" }, + "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" } +}
D

@@ -1,4 +0,0 @@

-require("nvim-autopairs").setup { - check_ts = true, - disable_filetype = { "TelescopePrompt" }, -}
D

@@ -1,110 +0,0 @@

-local cmp = require "cmp" -local luasnip = require "luasnip" - -cmp.event:on( - "confirm_done", - require("nvim-autopairs.completion.cmp").on_confirm_done { - map_char = { tex = "" }, - } -) - -cmp.setup.filetype({ "gitcommit", "NeogitCommitMessage" }, { - sources = { - { name = "buffer" }, - { name = "luasnip" }, - }, -}) - -cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - formatting = { - format = function(_, vim_item) - vim_item.kind = ({ - Text = "", - Method = "", - Function = "", - Constructor = "", - Field = "", - Variable = "", - Class = "", - Interface = "ﰮ", - Module = "", - Property = "", - Unit = "", - Value = "", - Enum = "", - Keyword = "", - Snippet = "﬌", - Color = "", - File = "", - Reference = "", - Folder = "", - EnumMember = "", - Constant = "", - Struct = "", - Event = "", - Operator = "ﬦ", - TypeParameter = "", - })[vim_item.kind] - - return vim_item - end, - }, - mapping = { - ["<C-j>"] = cmp.mapping.select_next_item(), - ["<C-k>"] = cmp.mapping.select_prev_item(), - ["<C-d>"] = cmp.mapping.scroll_docs(-4), - ["<C-f>"] = cmp.mapping.scroll_docs(4), - ["<C-Space>"] = cmp.mapping.complete {}, - ["<C-e>"] = cmp.mapping.close(), - ["<CR>"] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }, - ["<Tab>"] = function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - vim.fn.feedkeys( - vim.api.nvim_replace_termcodes( - "<Plug>luasnip-expand-or-jump", - true, - true, - true - ), - "" - ) - else - fallback() - end - end, - ["<S-Tab>"] = function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - vim.fn.feedkeys( - vim.api.nvim_replace_termcodes( - "<Plug>luasnip-jump-prev", - true, - true, - true - ), - "" - ) - else - fallback() - end - end, - }, - sources = { - { name = "nvim_lsp", max_item_count = 8 }, - { name = "buffer", max_item_count = 4 }, - { name = "luasnip", max_item_count = 3 }, - { name = "path", max_item_count = 2 }, - }, - experimental = { ghost_text = true }, -}
D

@@ -1,17 +0,0 @@

-local map = require("core.utils").expr - -map("i", "<C-;>", function() - return vim.fn["codeium#Accept"]() -end) - -map("i", "<C-,>", function() - return vim.fn["codeium#CycleCompletions"](1) -end) - -map("i", "<C-.>", function() - return vim.fn["codeium#CycleCompletions"](-1) -end) - -map("i", "<A-;>", function() - return vim.fn["codeium#"](-1) -end)
D

@@ -1,9 +0,0 @@

-require("nvim-dap-virtual-text").setup {} -require "configs.dap.ui" - -vim.fn.sign_define("DapBreakpoint", { - text = "", - texthl = "DiagnosticSignError", - linehl = "", - numhl = "", -})
D

@@ -1,12 +0,0 @@

-local dp = require "debugprint" -local u = require "core.utils" - -dp.setup {} - -u.expr("n", "<leader>P", function() - return require("debugprint").debugprint { variable = true } -end) - -u.map("n", "g?d", function() - dp.deleteprints() -end)
D

@@ -1,29 +0,0 @@

-require("gitsigns").setup { - max_file_length = 1000, - current_line_blame = true, - current_line_blame_opts = { - virt_text_pos = "eol", - delay = 300, - }, - on_attach = function(bufnr) - local g = package.loaded.gitsigns - local map = function(from, to) - vim.keymap.set("n", from, to, { - buffer = bufnr, - noremap = true, - silent = true, - }) - end - - map("]g", g.next_hunk) - map("[g", g.prev_hunk) - map("<leader>gs", g.stage_hunk) - map("<leader>gu", g.undo_stage_hunk) - map("<leader>gr", g.reset_hunk) - map("<leader>gp", g.preview_hunk) - map("<leader>gb", function() - g.blame_line { full = true } - end) - map("<leader>gd", g.diffthis) - end, -}
D

@@ -1,9 +0,0 @@

-require("illuminate").configure { - providers = { "lsp", "treesitter" }, - filetypes_denylist = { - "NvimTree", - "packer", - "NeogitStatus", - "TelescopePrompt", - }, -}
D

@@ -1,19 +0,0 @@

-require("configs.lsp.diagnostic").setup() -require "configs.lsp.inlayhints" -require "configs.lsp.null-ls" -require("mason-lspconfig").setup { - ensure_installed = { "sumneko_lua" }, -} - -local lspconfig = require "lspconfig" -local options = { - on_attach = require("configs.lsp.attach").common, - flags = { debounce_text_changes = 150 }, - capabilities = require("cmp_nvim_lsp").default_capabilities(), -} - -require("neodev").setup {} - -for name, conf in pairs(require "configs.lsp.servers") do - lspconfig[name].setup(vim.tbl_extend("force", options, conf)) -end
M lua/plugins/lsp/null-ls.lualua/plugins/lsp/null-ls.lua

@@ -4,7 +4,7 @@ local formatting = null_ls.builtins.formatting

local diagnostic = null_ls.builtins.diagnostics null_ls.setup { - on_attach = require("configs.lsp.attach").null_ls, + on_attach = require("plugins.lsp.attach").null_ls, sources = { formatting.stylua, diagnostic.selene,
M lua/plugins/lsp/servers.lualua/plugins/lsp/servers.lua

@@ -3,7 +3,16 @@

return { denols = { root_dir = lspconfig.util.root_pattern("deno.json", "deno.jsonc") }, tsserver = { root_dir = lspconfig.util.root_pattern "package.json" }, - emmet_ls = { filetypes = { "html", "typescriptreact", "javascriptreact", "css", "scss", "astro" }}, + emmet_ls = { + filetypes = { + "html", + "typescriptreact", + "javascriptreact", + "css", + "scss", + "astro", + }, + }, astro = {}, dockerls = {}, gopls = {
D

@@ -1,51 +0,0 @@

-local c = { - mode = { - function() - return " " - end, - padding = 0, - }, - diagnostic = { "diagnostics", sources = { "nvim_diagnostic" } }, - location = { "location", padding = 1, colored = false }, - lsp = { - function() - local clients = vim.lsp.get_active_clients { bufnr = 0 } - local client_names = {} - for _, client in pairs(clients) do - if client.name ~= "null-ls" then - table.insert(client_names, client.name) - end - end - - local client_names_str = table.concat(client_names, ", ") - if #client_names_str == 0 then - return "" - else - return "[" .. client_names_str .. "]" - end - end, - }, -} - -require("lualine").setup { - options = { - theme = "tokyonight", - globalstatus = true, - component_separators = { left = "", right = "" }, - section_separators = { left = "", right = "" }, - disabled_filetypes = { - "NvimTree", - "TelescopePrompt", - "NeogitStatus", - "packer", - }, - }, - sections = { - lualine_a = { c.mode }, - lualine_b = {}, - lualine_c = { "filename", "branch", c.diagnostic }, - lualine_x = { c.lsp, "diff" }, - lualine_y = {}, - lualine_z = { c.location }, - }, -}
D

@@ -1,49 +0,0 @@

-local map = require("core.utils").map -local ls = require "luasnip" -local types = require "luasnip.util.types" -local fmt = require("luasnip.extras.fmt").fmt -local extras = require "luasnip.extras" - -ls.config.set_config { - history = true, - updateevents = "TextChanged,TextChangedI", - region_check_events = "CursorMoved,CursorHold,InsertEnter", - delete_check_events = "InsertLeave", - snip_env = { - fmt = fmt, - rep = extras.rep, - m = extras.match, - l = extras.lamda, - s = ls.snippet, - t = ls.text_node, - f = ls.function_node, - c = ls.choice_node, - d = ls.dynamic_node, - i = ls.insert_node, - }, - ext_opts = { - [types.choiceNode] = { - passive = { - virt_text = { { "●", "Operator" } }, - hl_group = "LuaSnipChoiceNode", - }, - }, - [types.insertNode] = { - active = { - virt_text = { { "●", "Type" } }, - hl_group = "LuaSnipInsertNode", - }, - }, - }, -} - -require("luasnip.loaders.from_lua").lazy_load() -require("luasnip.loaders.from_vscode").lazy_load() - -map({ "s", "i" }, "<C-l>", function() - if ls.choice_active() then - ls.change_choice(1) - elseif ls.expand_or_jumpable() then - ls.expand_or_jump() - end -end)
D

@@ -1,11 +0,0 @@

-require("neogit").setup { - kind = "vsplit", - disable_builtin_notifications = true, - disable_commit_confirmation = true, - disable_hint = true, - signs = { - section = { "", "" }, - item = { "", "" }, - hunk = { "", "" }, - }, -}
D

@@ -1,44 +0,0 @@

---# selene: allow(multiple_statements) -local neotest = require "neotest" -local map = require("core.utils").map - -neotest.setup { - adapters = { - require "neotest-go" { experimental = { test_table = true } }, - require "neotest-plenary", - }, - icons = { - expanded = "", - child_prefix = "", - child_indent = "", - final_child_prefix = "", - non_collapsible = "", - collapsed = "", - passed = "", - running = "", - failed = "", - unknown = "", - }, - summary = { - mappings = { - expand = { "l", "h", "<CR>" }, - stop = "s", - }, - }, -} - --- stylua: ignore start -map("n", "<leader>tn", neotest.run.run) -map("n", "<leader>ts", neotest.summary.toggle) -map("n", "<leader>ta", neotest.run.attach) -map("n", "<leader>tS", neotest.run.stop) -map("n", "<leader>to", neotest.output.open) -map("n", "]t", neotest.jump.next) -map("n", "[t", neotest.jump.prev) -map("n", "]T", function() neotest.jump.next { status = "failed" } end) -map("n", "[T", function() neotest.jump.prev { status = "failed" } end) -map("n", "<leader>td", function() neotest.run.run { strategy = "dap" } end) -map("n", "<leader>tt", function() - neotest.run.run(vim.fn.expand "%") ---@diagnostic disable-line: missing-parameter -end) --- stylua: ignore end
D

@@ -1,27 +0,0 @@

-require("nvim-tree").setup { - diagnostics = { enable = true }, - renderer = { group_empty = true }, - git = { enable = true }, - filters = { - dotfiles = true, - custom = { - "^\\.git$", - "^\\.bin$", - "node_modules", - "__pycache__", - "vendor", - "target", - }, - }, - view = { - side = "right", - mappings = { - list = { - { key = { "l", "<CR>", "o" }, action = "edit" }, - { key = "h", action = "close_node" }, - { key = "v", action = "vsplit" }, - { key = "s", action = "split" }, - }, - }, - }, -}
D

@@ -1,14 +0,0 @@

-require("project_nvim").setup { - show_hidden = true, - patterns = { - "^\\.git$", - "Makefile", - "Justfile", - "package.json", - "go.mod", - "go.work", - "pyproject.toml", - "Cargo.toml", - "deps.edn", - }, -}
D

@@ -1,50 +0,0 @@

-local telescope = require "telescope" -local actions = require "telescope.actions" - -telescope.setup { - defaults = { - prompt_prefix = " ", - selection_caret = " ", - file_ignore_patterns = { - "^\\.git$", - "^\\.bin$", - "node_modules", - "__pycache__", - "target", - "vendor", - }, - mappings = { - i = { - ["<esc>"] = actions.close, - ["<C-j>"] = actions.move_selection_next, - ["<C-k>"] = actions.move_selection_previous, - ["<C-d>"] = actions.delete_buffer, - }, - n = { - ["<C-j>"] = actions.move_selection_next, - ["<C-k>"] = actions.move_selection_previous, - ["<C-d>"] = actions.delete_buffer, - }, - }, - }, - pickers = { - find_files = { theme = "ivy" }, - live_grep = { theme = "ivy" }, - buffers = { theme = "ivy" }, - oldfiles = { theme = "ivy" }, - keymaps = { theme = "ivy" }, - git_branches = { theme = "ivy" }, - git_commits = { theme = "ivy" }, - git_status = { theme = "ivy" }, - lsp_definitions = { theme = "ivy" }, - lsp_references = { theme = "ivy" }, - lsp_implementations = { theme = "ivy" }, - lsp_document_symbols = { theme = "ivy" }, - }, - extensions = { - ["ui-select"] = { require("telescope.themes").get_ivy {} }, - }, -} - -telescope.load_extension "projects" -telescope.load_extension "ui-select"
D

@@ -1,8 +0,0 @@

-require("nvim-treesitter.configs").setup { - ensure_installed = { "lua", "go", "gomod", "gowork", "make" }, - indent = { enable = true, disable = { "python" } }, - highlight = { enable = true, additional_vim_regex_highlighting = false }, - autopairs = { enable = true }, - endwise = { enable = true }, - rainbow = { enable = true }, -}
M lua/core/keymaps.lua

@@ -41,29 +41,5 @@ map("v", "<", "<gv")

map("v", ">", ">gv") -- plugins -map("n", "<leader>e", vim.cmd.NvimTreeToggle) +map("n", "<leader>L", vim.cmd.Lazy) map("n", "<leader>u", vim.cmd.UndotreeToggle) -map("n", "<leader>ps", vim.cmd.PackerSync) -map("n", "<leader>pc", vim.cmd.PackerCompile) -map("n", "<leader>gg", vim.cmd.Neogit) - --- telescope -map("n", "<leader>f", "<cmd>Telescope find_files<cr>") -map("n", "<leader>b", "<cmd>Telescope buffers<cr>") -map("n", "<leader>sr", "<cmd>Telescope oldfiles<cr>") -map("n", "<leader>sb", "<cmd>Telescope git_branches<cr>") -map("n", "<leader>st", "<cmd>Telescope live_grep<cr>") -map("n", "<leader>sp", "<cmd>Telescope projects<cr>") -map("n", "<leader>sf", "<cmd>Telescope git_bcommits<cr>") -map("n", "<leader>sc", "<cmd>Telescope git_commits<cr>") - --- dap -map("n", "<leader>db", "<cmd>lua require'dap'.toggle_breakpoint()<cr>") -map("n", "<leader>dc", "<cmd>lua require'dap'.continue()<cr>") -map("n", "<leader>di", "<cmd>lua require'dap'.step_into()<cr>") -map("n", "<leader>do", "<cmd>lua require'dap'.step_over()<cr>") -map("n", "<leader>dO", "<cmd>lua require'dap'.step_out()<cr>") -map("n", "<leader>dr", "<cmd>lua require'dap'.repl.toggle()<cr>") -map("n", "<leader>dl", "<cmd>lua require'dap'.run_last()<cr>") -map("n", "<leader>du", "<cmd>lua require'dapui'.toggle()<cr>") -map("n", "<leader>dt", "<cmd>lua require'dap'.terminate()<cr>")
A lua/core/lazy.lua

@@ -0,0 +1,42 @@

+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", + lazypath, + } +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup("plugins", { + defaults = { lazy = true }, + dev = { path = "~/code" }, + performance = { + rtp = { + disabled_plugins = { + "netrw", + "netrwPlugin", + "netrwSettings", + "netrwFileHandlers", + "gzip", + "zip", + "tohtml", + "man", + "zipPlugin", + "tar", + "tarPlugin", + "getscript", + "getscriptPlugin", + "vimball", + "vimballPlugin", + "2html_plugin", + "logipat", + "rrhelper", + "spellfile_plugin", + "matchit", + }, + }, + }, +})
M lua/core/options.lua

@@ -1,5 +1,3 @@

-pcall(vim.cmd.colorscheme, "tokyonight-night") - vim.g.undotree_DiffAutoOpen = 0 -- leader

@@ -53,27 +51,3 @@ -- disable build-in modules

vim.g.loaded_perl_provider = 0 vim.g.loaded_ruby_provider = 0 vim.g.loaded_node_provider = 0 -for _, i in pairs { - "netrw", - "netrwPlugin", - "netrwSettings", - "netrwFileHandlers", - "gzip", - "zip", - "tohtml", - "man", - "zipPlugin", - "tar", - "tarPlugin", - "getscript", - "getscriptPlugin", - "vimball", - "vimballPlugin", - "2html_plugin", - "logipat", - "rrhelper", - "spellfile_plugin", - "matchit", -} do - vim.g["loaded_" .. i] = 1 -end
M lua/core/utils.lua

@@ -13,17 +13,17 @@ expr = function(mode, from, to)

vim.keymap.set(mode, from, to, { noremap = true, expr = true }) end, - get = { - ---@param path string - ---@return string - config = function(path) - return string.format("require[[configs.%s]]", path) - end, - - ---@param path string - ---@return string - setup = function(path) - return string.format("require[[%s]].setup()", path) - end, - }, + ---@param module string + ---@param method string + ---@param args string|nil + ---@return string + smap = function(module, method, args) + args = args or "" + return string.format( + "<cmd>lua require'%s'.%s(%s)<cr>", + module, + method, + args + ) + end, }
M lua/plugins.lua

@@ -1,166 +1,25 @@

-local packer = require "packer" -local u = require "core.utils" - -packer.init { - profile = { enable = true }, - display = { - open_fn = function() - return require("packer.util").float { border = "single" } - end, - }, -} - -return packer.startup(function(use) - use "wbthomason/packer.nvim" - use "nvim-lua/plenary.nvim" - use "lewis6991/impatient.nvim" - use "folke/tokyonight.nvim" -- theme - - use { "~/code/gopher.nvim", ft = "go", module = "gopher" } - use { "tpope/vim-surround", keys = { "c", "d", "y" } } - use { "kyazdani42/nvim-web-devicons", module = "nvim-web-devicons" } - use { "ahmedkhalf/project.nvim", config = u.get.config "project" } - use { "mbbill/undotree", cmd = "UndotreeToggle" } - -- use { "gpanders/editorconfig.nvim", event = "BufRead" } - - use { -- commenting helper +return { + "nvim-lua/plenary.nvim", + "kyazdani42/nvim-web-devicons", + { "olexsmir/gopher.nvim", ft = "go", dev = true }, + { "mbbill/undotree", cmd = "UndotreeToggle" }, + { "tpope/vim-surround", keys = { "c", "d", "y" } }, + { "gpanders/editorconfig.nvim", event = "BufRead" }, + { "tpope/vim-repeat", event = "VeryLazy" }, + { "numToStr/Comment.nvim", keys = "gc", event = "BufRead", - config = u.get.setup "Comment", - } - - use { -- auto pairs closer - "windwp/nvim-autopairs", - event = "InsertEnter", - module = "nvim-autopairs", - config = u.get.config "autopairs", - } - - use { -- status line - "nvim-lualine/lualine.nvim", - after = "tokyonight.nvim", - config = u.get.config "lualine", - } - - use { -- higlight todo, note, fix comments + config = true, + }, + { "folke/todo-comments.nvim", event = "BufRead", - config = u.get.setup "todo-comments", - } - - -- git - use { - "lewis6991/gitsigns.nvim", - event = "BufRead", - config = u.get.config "gitsigns", - } - - use { - "TimUntersberger/neogit", - cmd = "Neogit", - config = u.get.config "neogit", - } - - -- picker & file explorer - use { - "nvim-telescope/telescope.nvim", - config = u.get.config "telescope", - requires = { "nvim-telescope/telescope-ui-select.nvim" }, - } - - use { - "kyazdani42/nvim-tree.lua", - cmd = "NvimTreeToggle", - config = u.get.config "nvimtree", - } - - use { -- syntax - "nvim-treesitter/nvim-treesitter", - config = u.get.config "treesitter", - requires = { - { "RRethy/nvim-treesitter-endwise", after = "nvim-treesitter" }, - { "p00f/nvim-ts-rainbow", after = "nvim-treesitter" }, - }, - } - - use { -- AI completion - "Exafunction/codeium.vim", - config = u.get.config "codeium", - cmd = "Codeium", - event = "InsertEnter", - } - - use { -- test runner - "nvim-neotest/neotest", - config = u.get.config "neotest", - keys = { "<leader>t", "[t", "]t", "]T", "[T" }, - module = "neotest", - requires = { - { "nvim-neotest/neotest-go", module = "neotest-go" }, - { "nvim-neotest/neotest-plenary", module = "neotest-plenary" }, - }, - } - - -- meason - use { + config = true, + }, + { "williamboman/mason.nvim", event = "VimEnter", - config = u.get.setup "mason", - } - - -- deubugger - use { - "mfussenegger/nvim-dap", - module = "dap", - config = u.get.config "dap", - requires = { - { "rcarriga/nvim-dap-ui", module = "dapui" }, - { "theHamsta/nvim-dap-virtual-text", module = "nvim-dap-virtual-text" }, - }, - } - - use { - "andrewferrier/debugprint.nvim", - config = u.get.config "debugprint", - keys = { "<leader>P", "g?" }, - } - - -- lsp & completion - use { - "neovim/nvim-lspconfig", - event = "BufRead", - config = u.get.config "lsp", - requires = { - { "williamboman/mason-lspconfig.nvim", module = "mason-lspconfig" }, - { "jose-elias-alvarez/null-ls.nvim", module = "null-ls" }, - { "b0o/schemastore.nvim", modules = "schemastore" }, - { "folke/neodev.nvim", module = "neodev" }, - { "lvimuser/lsp-inlayhints.nvim", module = "lsp-inlayhints" }, - { - "RRethy/vim-illuminate", - after = "nvim-lspconfig", - config = u.get.config "illuminate", - }, - }, - } - - use { - "hrsh7th/nvim-cmp", - event = "BufRead", - config = u.get.config "cmp", - requires = { - { "hrsh7th/cmp-buffer", after = "nvim-cmp" }, - { "saadparwaiz1/cmp_luasnip", after = "nvim-cmp" }, - { "hrsh7th/cmp-path", after = "nvim-cmp" }, - { "hrsh7th/cmp-nvim-lsp", module = "cmp_nvim_lsp" }, - }, - } - - use { - "L3MON4D3/LuaSnip", - module = "luasnip", - config = u.get.config "luasnip", - requires = "rafamadriz/friendly-snippets", - } -end) + config = true, + }, +}
A lua/plugins/autopairs.lua

@@ -0,0 +1,8 @@

+return { + "windwp/nvim-autopairs", + event = "InsertEnter", + opts = { + check_ts = true, + disable_filetype = { "TelescopePrompt" }, + }, +}
A lua/plugins/cmp.lua

@@ -0,0 +1,122 @@

+return { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-buffer", + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-path", + "hrsh7th/cmp-nvim-lsp", + }, + config = function() + local cmp = require "cmp" + local luasnip = require "luasnip" + + cmp.event:on( + "confirm_done", + require("nvim-autopairs.completion.cmp").on_confirm_done { + map_char = { tex = "" }, + } + ) + + cmp.setup.filetype({ "gitcommit", "NeogitCommitMessage" }, { + sources = { + { name = "buffer" }, + { name = "luasnip" }, + }, + }) + + cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + formatting = { + format = function(_, vim_item) + vim_item.kind = ({ + Text = "", + Method = "", + Function = "", + Constructor = "", + Field = "", + Variable = "", + Class = "", + Interface = "ﰮ", + Module = "", + Property = "", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "﬌", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "ﬦ", + TypeParameter = "", + })[vim_item.kind] + + return vim_item + end, + }, + mapping = { + ["<C-j>"] = cmp.mapping.select_next_item(), + ["<C-k>"] = cmp.mapping.select_prev_item(), + ["<C-d>"] = cmp.mapping.scroll_docs(-4), + ["<C-f>"] = cmp.mapping.scroll_docs(4), + ["<C-Space>"] = cmp.mapping.complete {}, + ["<C-e>"] = cmp.mapping.close(), + ["<CR>"] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + ["<Tab>"] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + vim.fn.feedkeys( + vim.api.nvim_replace_termcodes( + "<Plug>luasnip-expand-or-jump", + true, + true, + true + ), + "" + ) + else + fallback() + end + end, + ["<S-Tab>"] = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + vim.fn.feedkeys( + vim.api.nvim_replace_termcodes( + "<Plug>luasnip-jump-prev", + true, + true, + true + ), + "" + ) + else + fallback() + end + end, + }, + sources = { + { name = "nvim_lsp", max_item_count = 8 }, + { name = "buffer", max_item_count = 4 }, + { name = "luasnip", max_item_count = 3 }, + { name = "path", max_item_count = 2 }, + }, + experimental = { ghost_text = true }, + } + end, +}
A lua/plugins/codeium.lua

@@ -0,0 +1,24 @@

+return { + "Exafunction/codeium.vim", + cmd = "Codeium", + event = "InsertEnter", + keys = { + { "<C-;>", vim.fn["codeium#Accept"], mode = "i", expr = true }, + { + "<C-,>", + function() + return vim.fn["codeium#CycleCompletions"](1) + end, + mode = "i", + expr = true, + }, + { + "<C-.>", + function() + return vim.fn["codeium#CycleCompletions"](-1) + end, + mode = "i", + expr = true, + }, + }, +}
A lua/plugins/colorscheme.lua

@@ -0,0 +1,7 @@

+return { + "folke/tokyonight.nvim", + lazy = false, + config = function() + vim.cmd.colorscheme "tokyonight-night" + end, +}
A lua/plugins/dap/init.lua

@@ -0,0 +1,27 @@

+return { + "mfussenegger/nvim-dap", + keys = { + { "<leader>db", "<cmd>lua require'dap'.toggle_breakpoint()<cr>" }, + { "<leader>dc", "<cmd>lua require'dap'.continue()<cr>" }, + { "<leader>di", "<cmd>lua require'dap'.step_into()<cr>" }, + { "<leader>do", "<cmd>lua require'dap'.step_over()<cr>" }, + { "<leader>dO", "<cmd>lua require'dap'.step_out()<cr>" }, + { "<leader>dr", "<cmd>lua require'dap'.repl.toggle()<cr>" }, + { "<leader>dl", "<cmd>lua require'dap'.run_last()<cr>" }, + { "<leader>du", "<cmd>lua require'dapui'.toggle()<cr>" }, + { "<leader>dt", "<cmd>lua require'dap'.terminate()<cr>" }, + }, + dependencies = { + "rcarriga/nvim-dap-ui", + { "theHamsta/nvim-dap-virtual-text", config = true }, + }, + config = function() + require "plugins.dap.ui" + vim.fn.sign_define("DapBreakpoint", { + text = "", + texthl = "DiagnosticSignError", + linehl = "", + numhl = "", + }) + end, +}
A lua/plugins/debugprint.lua

@@ -0,0 +1,14 @@

+return { + "andrewferrier/debugprint.nvim", + config = true, + keys = { + { + "<leader>P", + function() + return require("debugprint").debugprint { variable = true } + end, + expr = true, + }, + "g?", + }, +}
A lua/plugins/gitsigns.lua

@@ -0,0 +1,39 @@

+return { + "lewis6991/gitsigns.nvim", + event = "BufRead", + keys = { + "]g", + "[g", + "<leader>gs", + "<leader>gu", + "<leader>gr", + "<leader>gp", + "<leader>gd", + }, + opts = { + max_file_length = 1000, + current_line_blame = true, + current_line_blame_opts = { + virt_text_pos = "eol", + delay = 300, + }, + on_attach = function(bufnr) + local g = package.loaded.gitsigns + local map = function(from, to) + vim.keymap.set("n", from, to, { + buffer = bufnr, + noremap = true, + silent = true, + }) + end + + map("]g", g.next_hunk) + map("[g", g.prev_hunk) + map("<leader>gs", g.stage_hunk) + map("<leader>gu", g.undo_stage_hunk) + map("<leader>gr", g.reset_hunk) + map("<leader>gp", g.preview_hunk) + map("<leader>gd", g.diffthis) + end, + }, +}
A lua/plugins/lsp/init.lua

@@ -0,0 +1,41 @@

+return { + "neovim/nvim-lspconfig", + event = "BufRead", + dependencies = { + "williamboman/mason-lspconfig.nvim", + "jose-elias-alvarez/null-ls.nvim", + "b0o/schemastore.nvim", + "folke/neodev.nvim", + "lvimuser/lsp-inlayhints.nvim", + { + "RRethy/vim-illuminate", + config = function() + require("illuminate").configure { + providers = { "lsp", "treesitter" }, + filetypes_denylist = { + "NvimTree", + "packer", + "NeogitStatus", + "TelescopePrompt", + }, + } + end, + }, + }, + config = function() + local lspconfig = require "lspconfig" + require("plugins.lsp.diagnostic").setup() + require "plugins.lsp.inlayhints" + require "plugins.lsp.null-ls" + require("mason-lspconfig").setup { ensure_installed = { "sumneko_lua" } } + require("neodev").setup {} + + for name, conf in pairs(require "plugins.lsp.servers") do + lspconfig[name].setup(vim.tbl_extend("force", { + on_attach = require("plugins.lsp.attach").common, + flags = { debounce_text_changes = 150 }, + capabilities = require("cmp_nvim_lsp").default_capabilities(), + }, conf)) + end + end, +}
A lua/plugins/lualine.lua

@@ -0,0 +1,55 @@

+local c = { + mode = { + function() + return " " + end, + padding = 0, + }, + diagnostic = { "diagnostics", sources = { "nvim_diagnostic" } }, + location = { "location", padding = 1, colored = false }, + lsp = { + function() + local clients = vim.lsp.get_active_clients { bufnr = 0 } + local client_names = {} + for _, client in pairs(clients) do + if client.name ~= "null-ls" then + table.insert(client_names, client.name) + end + end + + local client_names_str = table.concat(client_names, ", ") + if #client_names_str == 0 then + return "" + else + return "[" .. client_names_str .. "]" + end + end, + }, +} + +return { + "nvim-lualine/lualine.nvim", + lazy = false, + opts = { + options = { + theme = "tokyonight", + globalstatus = true, + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + disabled_filetypes = { + "NvimTree", + "TelescopePrompt", + "NeogitStatus", + "packer", + }, + }, + sections = { + lualine_a = { c.mode }, + lualine_b = {}, + lualine_c = { "filename", "branch", c.diagnostic }, + lualine_x = { c.lsp, "diff" }, + lualine_y = {}, + lualine_z = { c.location }, + }, + }, +}
A lua/plugins/luasnip.lua

@@ -0,0 +1,55 @@

+return { + "L3MON4D3/LuaSnip", + dependencies = { "rafamadriz/friendly-snippets" }, + config = function() + local map = require("core.utils").map + local ls = require "luasnip" + local types = require "luasnip.util.types" + local fmt = require("luasnip.extras.fmt").fmt + local extras = require "luasnip.extras" + + ls.config.set_config { + history = true, + updateevents = "TextChanged,TextChangedI", + region_check_events = "CursorMoved,CursorHold,InsertEnter", + delete_check_events = "InsertLeave", + snip_env = { + fmt = fmt, + rep = extras.rep, + m = extras.match, + l = extras.lamda, + s = ls.snippet, + t = ls.text_node, + f = ls.function_node, + c = ls.choice_node, + d = ls.dynamic_node, + i = ls.insert_node, + }, + ext_opts = { + [types.choiceNode] = { + passive = { + virt_text = { { "●", "Operator" } }, + hl_group = "LuaSnipChoiceNode", + }, + }, + [types.insertNode] = { + active = { + virt_text = { { "●", "Type" } }, + hl_group = "LuaSnipInsertNode", + }, + }, + }, + } + + require("luasnip.loaders.from_lua").lazy_load() + require("luasnip.loaders.from_vscode").lazy_load() + + map({ "s", "i" }, "<C-l>", function() + if ls.choice_active() then + ls.change_choice(1) + elseif ls.expand_or_jumpable() then + ls.expand_or_jump() + end + end) + end, +}
A lua/plugins/neogit.lua

@@ -0,0 +1,18 @@

+return { + "TimUntersberger/neogit", + cmd = "Neogit", + keys = { + { "<leader>gg", vim.cmd.Neogit }, + }, + opts = { + kind = "vsplit", + disable_builtin_notifications = true, + disable_commit_confirmation = true, + disable_hint = true, + signs = { + section = { "", "" }, + item = { "", "" }, + hunk = { "", "" }, + }, + }, +}
A lua/plugins/neotest.lua

@@ -0,0 +1,52 @@

+local map = require("core.utils").smap +return { + "nvim-neotest/neotest", + keys = { + { "<leader>tn", map("neotest", "run.run") }, + { "<leader>ta", map("neotest", "run.attach") }, + { "<leader>ts", map("neotest", "summary.toggle") }, + { "<leader>tS", map("neotest", "run.stop") }, + { "<leader>to", map("neotest", "output.open") }, + { "]t", map("neotest", "jump.next") }, + { "[t", map("neotest", "jump.prev") }, + { "]T", map("neotest", "jump.next", "{status = 'failed'}") }, + { "]T", map("neotest", "jump.next", "{status = 'failed'}") }, + { "<leader>td", map("neotest", "run.run", "{strategy = 'dap'}") }, + { + "<leader>tt", + function() + require("neotest").run.run(vim.fn.expand "%") + end, + }, + }, + dependencies = { + "nvim-neotest/neotest-go", + "nvim-neotest/neotest-plenary", + }, + config = function() + require("neotest").setup { + adapters = { + require "neotest-go" { experimental = { test_table = true } }, + require "neotest-plenary", + }, + icons = { + expanded = "", + child_prefix = "", + child_indent = "", + final_child_prefix = "", + non_collapsible = "", + collapsed = "", + passed = "", + running = "", + failed = "", + unknown = "", + }, + summary = { + mappings = { + expand = { "l", "h", "<CR>" }, + stop = "s", + }, + }, + } + end, +}
A lua/plugins/nvimtree.lua

@@ -0,0 +1,34 @@

+return { + "kyazdani42/nvim-tree.lua", + cmd = "NvimTreeToggle", + keys = { + { "<leader>e", vim.cmd.NvimTreeToggle }, + }, + opts = { + diagnostics = { enable = true }, + renderer = { group_empty = true }, + git = { enable = true }, + filters = { + dotfiles = true, + custom = { + "^\\.git$", + "^\\.bin$", + "node_modules", + "__pycache__", + "vendor", + "target", + }, + }, + view = { + side = "right", + mappings = { + list = { + { key = { "l", "<CR>", "o" }, action = "edit" }, + { key = "h", action = "close_node" }, + { key = "v", action = "vsplit" }, + { key = "s", action = "split" }, + }, + }, + }, + }, +}
A lua/plugins/project.lua

@@ -0,0 +1,20 @@

+return { + "ahmedkhalf/project.nvim", + lazy = false, + config = function() + require("project_nvim").setup { + show_hidden = true, + patterns = { + "^\\.git$", + "Makefile", + "Justfile", + "package.json", + "go.mod", + "go.work", + "pyproject.toml", + "Cargo.toml", + "deps.edn", + }, + } + end, +}
A lua/plugins/telescope.lua

@@ -0,0 +1,67 @@

+return { + "nvim-telescope/telescope.nvim", + lazy = false, + dependencies = { "nvim-telescope/telescope-ui-select.nvim" }, + keys = { + { "<leader>f", "<cmd>Telescope find_files<cr>" }, + { "<leader>b", "<cmd>Telescope buffers<cr>" }, + { "<leader>sr", "<cmd>Telescope oldfiles<cr>" }, + { "<leader>sb", "<cmd>Telescope git_branches<cr>" }, + { "<leader>st", "<cmd>Telescope live_grep<cr>" }, + { "<leader>sp", "<cmd>Telescope projects<cr>" }, + { "<leader>sf", "<cmd>Telescope git_bcommits<cr>" }, + { "<leader>sc", "<cmd>Telescope git_commits<cr>" }, + }, + config = function() + local telescope = require "telescope" + local actions = require "telescope.actions" + + telescope.setup { + defaults = { + prompt_prefix = " ", + selection_caret = " ", + file_ignore_patterns = { + "^\\.git$", + "^\\.bin$", + "node_modules", + "__pycache__", + "target", + "vendor", + }, + mappings = { + i = { + ["<esc>"] = actions.close, + ["<C-j>"] = actions.move_selection_next, + ["<C-k>"] = actions.move_selection_previous, + ["<C-d>"] = actions.delete_buffer, + }, + n = { + ["<C-j>"] = actions.move_selection_next, + ["<C-k>"] = actions.move_selection_previous, + ["<C-d>"] = actions.delete_buffer, + }, + }, + }, + pickers = { + find_files = { theme = "ivy" }, + live_grep = { theme = "ivy" }, + buffers = { theme = "ivy" }, + oldfiles = { theme = "ivy" }, + keymaps = { theme = "ivy" }, + git_branches = { theme = "ivy" }, + git_commits = { theme = "ivy" }, + git_status = { theme = "ivy" }, + lsp_definitions = { theme = "ivy" }, + lsp_references = { theme = "ivy" }, + lsp_implementations = { theme = "ivy" }, + lsp_document_symbols = { theme = "ivy" }, + }, + extensions = { + ["ui-select"] = { require("telescope.themes").get_ivy {} }, + }, + } + + telescope.load_extension "projects" + telescope.load_extension "ui-select" + end, +}
A lua/plugins/treesitter.lua

@@ -0,0 +1,18 @@

+return { + "nvim-treesitter/nvim-treesitter", + event = "BufReadPost", + dependencies = { + "RRethy/nvim-treesitter-endwise", + "p00f/nvim-ts-rainbow", + }, + config = function() + require("nvim-treesitter.configs").setup { + ensure_installed = { "lua", "go", "gomod", "gowork", "make" }, + indent = { enable = true, disable = { "python" } }, + highlight = { enable = true, additional_vim_regex_highlighting = false }, + autopairs = { enable = true }, + endwise = { enable = true }, + rainbow = { enable = true }, + } + end, +}