diff --git a/config/nvim/lua/config/keymaps/lsp.lua b/config/nvim/lua/config/keymaps/lsp.lua index e8ae0d1..9dbd640 100644 --- a/config/nvim/lua/config/keymaps/lsp.lua +++ b/config/nvim/lua/config/keymaps/lsp.lua @@ -17,6 +17,7 @@ keymap( 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" diff --git a/config/nvim/lua/config/plugins/ascii.lua b/config/nvim/lua/config/plugins/ascii.lua new file mode 100644 index 0000000..3c4566e --- /dev/null +++ b/config/nvim/lua/config/plugins/ascii.lua @@ -0,0 +1,7 @@ +return { + "MaximilianLloyd/ascii.nvim", + + dependencies = { + "MunifTanjim/nui.nvim", + }, +} diff --git a/config/nvim/lua/config/plugins/dashboard.lua b/config/nvim/lua/config/plugins/dashboard.lua index 7fc3a6b..26537bc 100644 --- a/config/nvim/lua/config/plugins/dashboard.lua +++ b/config/nvim/lua/config/plugins/dashboard.lua @@ -1,24 +1,30 @@ -return function() - require("dashboard").setup({ - theme = "hyper", - config = { - header = { - [[ . . ]], - [[ ';;,. ::' ]], - [[ ,:::;,, :ccc, ]], - [[,::c::,,,,. :cccc,]], - [[,cccc:;;;;;. cllll,]], - [[,cccc;.;;;;;, cllll;]], - [[:cccc; .;;;;;;. coooo;]], - [[;llll; ,:::::'loooo;]], - [[;llll: ':::::loooo:]], - [[:oooo: .::::llodd:]], - [[.;ooo: ;cclooo:.]], - [[ .;oc 'coo;. ]], - [[ .' .,. ]], - [[]], - [[]], +return { + "glepnir/dashboard-nvim", + + event = "VimEnter", + + config = function() + require("dashboard").setup({ + theme = "hyper", + config = { + header = { + [[ . . ]], + [[ ';;,. ::' ]], + [[ ,:::;,, :ccc, ]], + [[,::c::,,,,. :cccc,]], + [[,cccc:;;;;;. cllll,]], + [[,cccc;.;;;;;, cllll;]], + [[:cccc; .;;;;;;. coooo;]], + [[;llll; ,:::::'loooo;]], + [[;llll: ':::::loooo:]], + [[:oooo: .::::llodd:]], + [[.;ooo: ;cclooo:.]], + [[ .;oc 'coo;. ]], + [[ .' .,. ]], + [[]], + [[]], + }, }, - }, - }) -end + }) + end, +} diff --git a/config/nvim/lua/config/plugins/gitsigns.lua b/config/nvim/lua/config/plugins/gitsigns.lua new file mode 100644 index 0000000..8636c9d --- /dev/null +++ b/config/nvim/lua/config/plugins/gitsigns.lua @@ -0,0 +1,7 @@ +return { + "lewis6991/gitsigns.nvim", + + config = function() + require("gitsigns").setup() + end, +} diff --git a/config/nvim/lua/config/plugins/lspconfig/init.lua b/config/nvim/lua/config/plugins/lspconfig/init.lua index 04818b8..3131ca4 100644 --- a/config/nvim/lua/config/plugins/lspconfig/init.lua +++ b/config/nvim/lua/config/plugins/lspconfig/init.lua @@ -1,8 +1,12 @@ -return function() - require("config.plugins.lspconfig.elixir") - require("config.plugins.lspconfig.emmet") - require("config.plugins.lspconfig.javascript") - require("config.plugins.lspconfig.lua") - require("config.plugins.lspconfig.ruby") - require("config.plugins.lspconfig.rust") -end +return { + "neovim/nvim-lspconfig", + + config = function() + require("config.plugins.lspconfig.elixir") + require("config.plugins.lspconfig.emmet") + require("config.plugins.lspconfig.javascript") + require("config.plugins.lspconfig.lua") + require("config.plugins.lspconfig.ruby") + require("config.plugins.lspconfig.rust") + end, +} diff --git a/config/nvim/lua/config/plugins/lualine.lua b/config/nvim/lua/config/plugins/lualine.lua index 13145f8..3b2d86f 100644 --- a/config/nvim/lua/config/plugins/lualine.lua +++ b/config/nvim/lua/config/plugins/lualine.lua @@ -1,3 +1,9 @@ -return function() - require("lualine").setup() -end +return { + "nvim-lualine/lualine.nvim", + + dependencies = { "nvim-tree/nvim-web-devicons" }, + + config = function() + require("lualine").setup() + end, +} diff --git a/config/nvim/lua/config/plugins/mason.lua b/config/nvim/lua/config/plugins/mason.lua new file mode 100644 index 0000000..0144b89 --- /dev/null +++ b/config/nvim/lua/config/plugins/mason.lua @@ -0,0 +1,7 @@ +return { + "williamboman/mason.nvim", + + config = function() + require("mason").setup() + end, +} diff --git a/config/nvim/lua/config/plugins/neo-tree.lua b/config/nvim/lua/config/plugins/neo-tree.lua index 8b7b9e2..10eb2d5 100644 --- a/config/nvim/lua/config/plugins/neo-tree.lua +++ b/config/nvim/lua/config/plugins/neo-tree.lua @@ -1,8 +1,18 @@ -return function() - -- Unless you are still migrating, remove the deprecated commands from v1.x - vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) +return { + "nvim-neo-tree/neo-tree.nvim", - require("neo-tree").setup({ - hijack_netrw_behavior = "open_default", - }) -end + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + + config = function() + -- Unless you are still migrating, remove the deprecated commands from v1.x + vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) + + require("neo-tree").setup({ + hijack_netrw_behavior = "open_default", + }) + end, +} diff --git a/config/nvim/lua/config/plugins/null-ls.lua b/config/nvim/lua/config/plugins/null-ls.lua index baa04c3..7302119 100644 --- a/config/nvim/lua/config/plugins/null-ls.lua +++ b/config/nvim/lua/config/plugins/null-ls.lua @@ -1,39 +1,45 @@ -return function() - local null_ls = require("null-ls") +return { + "jose-elias-alvarez/null-ls.nvim", - null_ls.setup({ - sources = { - null_ls.builtins.formatting.crystal_format, - null_ls.builtins.formatting.prettierd.with({ - filetypes = { - "css", - "graphql", - "handlebars", - "html", - "javascript", - "javascriptreact", - "json", - "jsonc", - "less", - "markdown", - "markdown.mdx", - "ruby", - "scss", - "typescript", - "typescriptreact", - "vue", - "yaml", - }, - timeout = 5000, - }), - null_ls.builtins.formatting.rustfmt, - null_ls.builtins.formatting.standardrb, - null_ls.builtins.formatting.stylua, - }, - }) + dependencies = { "nvim-lua/plenary.nvim" }, - -- Format on save - vim.api.nvim_create_autocmd("BufWritePre", { - command = "lua vim.lsp.buf.format()", - }) -end + config = function() + local null_ls = require("null-ls") + + null_ls.setup({ + sources = { + null_ls.builtins.formatting.crystal_format, + null_ls.builtins.formatting.prettierd.with({ + filetypes = { + "css", + "graphql", + "handlebars", + "html", + "javascript", + "javascriptreact", + "json", + "jsonc", + "less", + "markdown", + "markdown.mdx", + "ruby", + "scss", + "typescript", + "typescriptreact", + "vue", + "yaml", + }, + timeout = 5000, + }), + null_ls.builtins.formatting.rustfmt, + null_ls.builtins.formatting.standardrb, + null_ls.builtins.formatting.stylua, + }, + }) + + -- Format on save + vim.api.nvim_create_autocmd("BufWritePre", { + command = "lua vim.lsp.buf.format()", + }) + end, +} diff --git a/config/nvim/lua/config/plugins/nvim-cmp.lua b/config/nvim/lua/config/plugins/nvim-cmp.lua index baf4a5e..072e80e 100644 --- a/config/nvim/lua/config/plugins/nvim-cmp.lua +++ b/config/nvim/lua/config/plugins/nvim-cmp.lua @@ -1,54 +1,66 @@ local has_words_before = function() local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + return col ~= 0 + and vim.api + .nvim_buf_get_lines(0, line - 1, line, true)[1] + :sub(col, col) + :match("%s") + == nil end local feedkey = function(key, mode) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) + vim.api.nvim_feedkeys( + vim.api.nvim_replace_termcodes(key, true, true, true), + mode, + true + ) end -return function() - local cmp = require("cmp") +return { + "hrsh7th/nvim-cmp", + config = function() + local cmp = require("cmp") - cmp.setup({ - snippet = { - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) - end, - }, - window = { - -- completion = cmp.config.window.bordered(), - -- documentation = cmp.config.window.bordered(), - }, - 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 - cmp.select_next_item() - elseif vim.fn["vsnip#available"](1) == 1 then - feedkey("(vsnip-expand-or-jump)", "") - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function() - if cmp.visible() then - cmp.select_prev_item() - elseif vim.fn["vsnip#jumpable"](-1) == 1 then - feedkey("(vsnip-jump-prev)", "") - end - end, { "i", "s" }) - }), - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "vsnip" }, - }, { - { name = "buffer" }, - }), - }) -end + cmp.setup({ + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + window = { + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + }, + 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 + cmp.select_next_item() + elseif vim.fn["vsnip#available"](1) == 1 then + feedkey("(vsnip-expand-or-jump)", "") + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function() + if cmp.visible() then + cmp.select_prev_item() + elseif vim.fn["vsnip#jumpable"](-1) == 1 then + feedkey("(vsnip-jump-prev)", "") + end + end, { "i", "s" }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "vsnip" }, + }, { + { name = "buffer" }, + }), + }) + end, +} diff --git a/config/nvim/lua/config/plugins/nvim-test.lua b/config/nvim/lua/config/plugins/nvim-test.lua new file mode 100644 index 0000000..56d3422 --- /dev/null +++ b/config/nvim/lua/config/plugins/nvim-test.lua @@ -0,0 +1,7 @@ +return { + "klen/nvim-test", + + config = function() + require("nvim-test").setup() + end, +} diff --git a/config/nvim/lua/config/plugins/nvim-treesitter.lua b/config/nvim/lua/config/plugins/nvim-treesitter.lua new file mode 100644 index 0000000..2d69064 --- /dev/null +++ b/config/nvim/lua/config/plugins/nvim-treesitter.lua @@ -0,0 +1,82 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + + build = ":TSUpdate", + + event = { "BufReadPost", "BufNewFile" }, + + dependencies = { + { + "nvim-treesitter/nvim-treesitter-textobjects", + init = function() + -- PERF: no need to load the plugin, + -- if we only need its queries for mini.ai + local plugin = + require("lazy.core.config").spec.plugins["nvim-treesitter"] + local opts = require("lazy.core.plugin").values(plugin, "opts", false) + local enabled = false + + if opts.textobjects then + for _, mod in ipairs({ "move", "select", "swap", "lsp_interop" }) do + if opts.textobjects[mod] and opts.textobjects[mod].enable then + enabled = true + break + end + end + end + + if not enabled then + require("lazy.core.loader").disable_rtp_plugin( + "nvim-treesitter-textobjects" + ) + end + end, + }, + "JoosepAlviste/nvim-ts-context-commentstring", + "RRethy/nvim-treesitter-endwise", + }, + + config = function() + require("nvim-treesitter.configs").setup({ + highlight = { enable = true }, + indent = { enable = true }, + endwise = { enable = true }, + context_commentstring = { enable = true }, + auto_install = true, + sync_install = false, + ensure_installed = { + "bash", + "c", + "comment", + "css", + "dockerfile", + "eex", + "elixir", + "html", + "javascript", + "json", + "lua", + "luadoc", + "luap", + "markdown", + "markdown_inline", + "python", + "query", + "regex", + "ruby", + "rust", + "scss", + "sql", + "swift", + "toml", + "tsx", + "typescript", + "vim", + "vue", + "yaml", + }, + }) + end, + }, +} diff --git a/config/nvim/lua/config/plugins/telescope.lua b/config/nvim/lua/config/plugins/telescope.lua new file mode 100644 index 0000000..458e0c2 --- /dev/null +++ b/config/nvim/lua/config/plugins/telescope.lua @@ -0,0 +1,5 @@ +return { + "nvim-telescope/telescope.nvim", + + dependencies = { "nvim-lua/plenary.nvim" }, +} diff --git a/config/nvim/lua/config/plugins/tree-sitter.lua b/config/nvim/lua/config/plugins/tree-sitter.lua deleted file mode 100644 index 7f3039a..0000000 --- a/config/nvim/lua/config/plugins/tree-sitter.lua +++ /dev/null @@ -1,41 +0,0 @@ -return function() - require("nvim-treesitter.configs").setup({ - highlight = { enable = true }, - indent = { enable = true }, - endwise = { enable = true }, - context_commentstring = { enable = true }, - auto_install = true, - sync_install = false, - ensure_installed = { - "bash", - "c", - "comment", - "css", - "dockerfile", - "eex", - "elixir", - "html", - "javascript", - "json", - "lua", - "luadoc", - "luap", - "markdown", - "markdown_inline", - "python", - "query", - "regex", - "ruby", - "rust", - "scss", - "sql", - "swift", - "toml", - "tsx", - "typescript", - "vim", - "vue", - "yaml", - }, - }) -end diff --git a/config/nvim/lua/config/plugins/treesj.lua b/config/nvim/lua/config/plugins/treesj.lua index 15a291c..28a70ed 100644 --- a/config/nvim/lua/config/plugins/treesj.lua +++ b/config/nvim/lua/config/plugins/treesj.lua @@ -1,3 +1,9 @@ -return function() - require("treesj").setup() -end +return { + "Wansmer/treesj", + + dependencies = { "nvim-treesitter/nvim-treesitter" }, + + config = function() + require("treesj").setup() + end, +} diff --git a/config/nvim/lua/config/plugins/which-key.lua b/config/nvim/lua/config/plugins/which-key.lua index a872790..47ebc51 100644 --- a/config/nvim/lua/config/plugins/which-key.lua +++ b/config/nvim/lua/config/plugins/which-key.lua @@ -1,10 +1,14 @@ -return function() - vim.o.timeout = true - vim.o.timeoutlen = 300 +return { + "folke/which-key.nvim", - require("which-key").setup({ - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - }) -end + config = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + + require("which-key").setup({ + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + }) + end, +} diff --git a/config/nvim/lua/plugins/init.lua b/config/nvim/lua/plugins/init.lua index f5eaac1..1fe16bb 100644 --- a/config/nvim/lua/plugins/init.lua +++ b/config/nvim/lua/plugins/init.lua @@ -1,74 +1,24 @@ return { - "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", "hrsh7th/cmp-cmdline", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-path", "hrsh7th/cmp-vsnip", "hrsh7th/vim-vsnip", - "tpope/vim-fugitive", "preservim/nerdcommenter", - { - "Wansmer/treesj", - dependencies = { "nvim-treesitter/nvim-treesitter" }, - config = require("config.plugins.treesj"), - }, - { - "MaximilianLloyd/ascii.nvim", - dependencies = { - "MunifTanjim/nui.nvim", - }, - }, - { - "glepnir/dashboard-nvim", - event = "VimEnter", - config = require("config.plugins.dashboard"), - dependencies = { { "nvim-tree/nvim-web-devicons" } }, - }, - { - "lewis6991/gitsigns.nvim", - config = function() - require("gitsigns").setup() - end, - }, - { - "hrsh7th/nvim-cmp", - config = require("config.plugins.nvim-cmp"), - }, - { - "williamboman/mason.nvim", - config = function() - require("mason").setup() - end, - }, - { - "neovim/nvim-lspconfig", - config = require("config.plugins.lspconfig"), - }, - { - "nvim-lualine/lualine.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - config = require("config.plugins.lualine"), - }, - { - "nvim-neo-tree/neo-tree.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - "MunifTanjim/nui.nvim", - }, - config = require("config.plugins.neo-tree"), - }, - { - "nvim-telescope/telescope.nvim", - dependencies = { "nvim-lua/plenary.nvim" }, - }, - { - "folke/which-key.nvim", - config = require("config.plugins.which-key"), - }, - { - "jose-elias-alvarez/null-ls.nvim", - dependencies = { "nvim-lua/plenary.nvim" }, - config = require("config.plugins.null-ls"), - }, + "tpope/vim-fugitive", + require("config.plugins.ascii"), + require("config.plugins.dashboard"), + require("config.plugins.gitsigns"), + require("config.plugins.lspconfig"), + require("config.plugins.lualine"), + require("config.plugins.mason"), + require("config.plugins.neo-tree"), + require("config.plugins.null-ls"), + require("config.plugins.nvim-cmp"), + require("config.plugins.nvim-test"), + require("config.plugins.nvim-treesitter"), + require("config.plugins.telescope"), + require("config.plugins.treesj"), + require("config.plugins.which-key"), } diff --git a/config/nvim/lua/plugins/tree-sitter.lua b/config/nvim/lua/plugins/tree-sitter.lua deleted file mode 100644 index 621c682..0000000 --- a/config/nvim/lua/plugins/tree-sitter.lua +++ /dev/null @@ -1,35 +0,0 @@ -return { - { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - event = { "BufReadPost", "BufNewFile" }, - dependencies = { - { - "nvim-treesitter/nvim-treesitter-textobjects", - init = function() - -- PERF: no need to load the plugin, if we only need its queries for mini.ai - local plugin = - require("lazy.core.config").spec.plugins["nvim-treesitter"] - local opts = require("lazy.core.plugin").values(plugin, "opts", false) - local enabled = false - if opts.textobjects then - for _, mod in ipairs({ "move", "select", "swap", "lsp_interop" }) do - if opts.textobjects[mod] and opts.textobjects[mod].enable then - enabled = true - break - end - end - end - if not enabled then - require("lazy.core.loader").disable_rtp_plugin( - "nvim-treesitter-textobjects" - ) - end - end, - }, - "JoosepAlviste/nvim-ts-context-commentstring", - "RRethy/nvim-treesitter-endwise", - }, - config = require("config.plugins.tree-sitter"), - }, -}