From 1864867434217edf5881eb7a9809902c2594488d Mon Sep 17 00:00:00 2001 From: 409 Date: Wed, 10 Apr 2024 10:58:10 +0200 Subject: [PATCH] migrated even more stuff from after to plugins --- after/plugin/barbecue.lua | 1 - after/plugin/cmp.lua | 62 ---------------------- after/plugin/conform.lua | 24 +-------- after/plugin/flutter-tools.lua | 1 - after/plugin/lsp.lua | 3 +- after/plugin/lualine.lua | 83 ----------------------------- after/plugin/todo.lua | 2 - after/plugin/treesitter.lua | 45 ---------------- after/plugin/trouble.lua | 6 --- after/plugin/undotree.lua | 1 - lua/409/plugins/comments.lua | 3 ++ lua/409/plugins/completion.lua | 82 ++++++++++++++++++++++++++--- lua/409/plugins/diagnostics.lua | 12 +++++ lua/409/plugins/extras/init.lua | 18 ++++--- lua/409/plugins/formatting.lua | 30 +++++++++++ lua/409/plugins/lsp.lua | 2 +- lua/409/plugins/statusline.lua | 92 +++++++++++++++++++++++++++++++++ lua/409/plugins/treesitter.lua | 63 +++++++++++++++++++--- lua/409/plugins/util.lua | 10 +++- 19 files changed, 290 insertions(+), 250 deletions(-) delete mode 100644 after/plugin/barbecue.lua delete mode 100644 after/plugin/cmp.lua delete mode 100644 after/plugin/flutter-tools.lua mode change 100755 => 100644 after/plugin/lsp.lua delete mode 100644 after/plugin/todo.lua mode change 100755 => 100644 after/plugin/treesitter.lua delete mode 100644 after/plugin/trouble.lua delete mode 100755 after/plugin/undotree.lua diff --git a/after/plugin/barbecue.lua b/after/plugin/barbecue.lua deleted file mode 100644 index 442b5f8..0000000 --- a/after/plugin/barbecue.lua +++ /dev/null @@ -1 +0,0 @@ -require("barbecue").setup() diff --git a/after/plugin/cmp.lua b/after/plugin/cmp.lua deleted file mode 100644 index 0621ccf..0000000 --- a/after/plugin/cmp.lua +++ /dev/null @@ -1,62 +0,0 @@ -local cmp = require("cmp") -local lspkind = require("lspkind") -local border = require('409.ui').border - -local cmp_select = { behavior = cmp.SelectBehavior.Select } -local winhighlight = "Normal:CmpPmenu,FloatBorder:CmpPmenuBorder,CursorLine:PmenuSel,Search:None" - - -cmp.setup({ - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - sources = { - { name = "nvim_lsp" }, - { name = "path" }, - { name = "nvim_lsp_signature_help" }, - { name = "nvim_lua" }, - { name = "luasnip", keyword_length = 2 }, - { name = "buffer", keyword_length = 3 }, - }, - view = { - entries = "custom", - }, - completion = { - completeopt = "menuone,noselect,preview", - docs_initially_visible = true, - }, - window = { - documentation = { - border = border, - winhighlight = winhighlight, - }, - completion = { - border = border, - winhighlight = winhighlight, - }, - }, - - formatting = { - fields = { "kind", "abbr", "menu" }, - format = function(entry, vim_item) - local kind = lspkind.cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item) - local strings = vim.split(kind.kind, "%s", { trimempty = true }) - kind.kind = " " .. (strings[1] or "") .. " " - kind.menu = " (" .. (strings[2] or "") .. ")" - - return kind - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_prev_item(cmp_select), - [""] = cmp.mapping.select_next_item(cmp_select), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.confirm({ select = true }), - [""] = cmp.mapping.complete(), - [""] = nil, - [""] = nil, - }), -}) diff --git a/after/plugin/conform.lua b/after/plugin/conform.lua index c4a625f..7ee8d81 100644 --- a/after/plugin/conform.lua +++ b/after/plugin/conform.lua @@ -1,25 +1,3 @@ local conform = require("conform") -conform.setup({ - formatters_by_ft = { - lua = { "stylua" }, - c = { "clang_format" }, - cs = { "csharpier" }, - javascript = { { "prettierd", "prettier" } }, - rust = { "rustfmt" }, - dart = { "dart_format" } - }, -}) +conform.setup() -conform.formatters.clang_format = { - args = { "--style", "{IndentWidth: 4, UseTab: Always, TabWidth: 4}" }, -} - -conform.formatters.rustfmt = { - args = { "--edition", "2021" }, -} - -vim.keymap.set("n", "f", function() - if not conform.format({ bufnr = vim.lsp.bufnr }) then - vim.lsp.buf.format() - end -end) diff --git a/after/plugin/flutter-tools.lua b/after/plugin/flutter-tools.lua deleted file mode 100644 index 3edc0bb..0000000 --- a/after/plugin/flutter-tools.lua +++ /dev/null @@ -1 +0,0 @@ -require("flutter-tools").setup({}) diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua old mode 100755 new mode 100644 index 9227b91..f397561 --- a/after/plugin/lsp.lua +++ b/after/plugin/lsp.lua @@ -6,7 +6,7 @@ local lsp_default_capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.tbl_deep_extend("force", {}, lsp_default_capabilities, default_capabilities) -require("mason").setup({}) +require("mason").setup() require("mason-lspconfig").setup({ ensure_installed = { "tsserver", "rust_analyzer" }, handlers = { @@ -16,7 +16,6 @@ require("mason-lspconfig").setup({ }) end, ["lua_ls"] = function() - local lspconfig = require("lspconfig") lspconfig.lua_ls.setup({ settings = { Lua = { diff --git a/after/plugin/lualine.lua b/after/plugin/lualine.lua index bf0623e..64186ee 100644 --- a/after/plugin/lualine.lua +++ b/after/plugin/lualine.lua @@ -1,86 +1,3 @@ -local theme = function() - local colors = { - darkgray = "#181825", - gray = "#cdd6f4", - innerbg = nil, - outerbg = "#313244", - normal = "#89b4fa", - insert = "#a6e3a1", - visual = "#cdd6f4", - replace = "#f38ba8", - command = "#fab387", - } - return { - inactive = { - a = { fg = colors.gray, bg = colors.outerbg, gui = "bold" }, - b = { fg = colors.gray, bg = colors.outerbg }, - c = { fg = colors.gray, bg = colors.innerbg }, - }, - visual = { - a = { fg = colors.darkgray, bg = colors.visual, gui = "bold" }, - b = { fg = colors.gray, bg = colors.outerbg }, - c = { fg = colors.gray, bg = colors.innerbg }, - }, - replace = { - a = { fg = colors.darkgray, bg = colors.replace, gui = "bold" }, - b = { fg = colors.gray, bg = colors.outerbg }, - c = { fg = colors.gray, bg = colors.innerbg }, - }, - normal = { - a = { fg = colors.darkgray, bg = colors.normal, gui = "bold" }, - b = { fg = colors.gray, bg = colors.outerbg }, - c = { fg = colors.gray, bg = colors.innerbg }, - }, - insert = { - a = { fg = colors.darkgray, bg = colors.insert, gui = "bold" }, - b = { fg = colors.gray, bg = colors.outerbg }, - c = { fg = colors.gray, bg = colors.innerbg }, - }, - command = { - a = { fg = colors.darkgray, bg = colors.command, gui = "bold" }, - b = { fg = colors.gray, bg = colors.outerbg }, - c = { fg = colors.gray, bg = colors.innerbg }, - }, - } -end require('lualine').setup { - options = { - icons_enabled = true, - theme = theme(), - component_separators = { left = '', right = '' }, - section_separators = { left = '', right = '' }, - disabled_filetypes = { - statusline = { 'packer' }, - winbar = {}, - }, - ignore_focus = {}, - always_divide_middle = true, - globalstatus = false, - refresh = { - statusline = 1000, - tabline = 1000, - winbar = 1000, - } - }, - sections = { - lualine_a = { 'mode' }, - lualine_b = { 'branch', 'diff', 'diagnostics' }, - lualine_c = { 'filename' }, - lualine_x = { 'encoding', 'fileformat', 'filetype' }, - lualine_y = { 'progress' }, - lualine_z = { 'location' } - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { 'filename' }, - lualine_x = { 'location' }, - lualine_y = {}, - lualine_z = {} - }, - tabline = {}, - winbar = {}, - inactive_winbar = {}, - extensions = {} } diff --git a/after/plugin/todo.lua b/after/plugin/todo.lua deleted file mode 100644 index abcfbbf..0000000 --- a/after/plugin/todo.lua +++ /dev/null @@ -1,2 +0,0 @@ --- local todo = require('todo-comments') --- todo.setup() diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua old mode 100755 new mode 100644 index 73b369c..6925ee6 --- a/after/plugin/treesitter.lua +++ b/after/plugin/treesitter.lua @@ -1,47 +1,2 @@ require("nvim-treesitter.configs").setup({ - -- A list of parser names, or "all" (the five listed parsers should always be installed) - ensure_installed = { - "javascript", - "typescript", - "c", - "lua", - "vim", - "vimdoc", - "query", - "c_sharp", - "css", - "gitcommit", - "html", - "svelte", - "yaml", - "astro", - "toml", - "jsdoc", - "json", - }, - - tree_docs = { - enable = true, - }, - - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, - - -- Automatically install missing parsers when entering buffer - -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally - auto_install = true, - - highlight = { - enable = true, - - -- Setting this to true will run `:h syntax` and tree-sitter at the same time. - -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). - -- Using this option may slow down your editor, and you may see some duplicate highlights. - -- Instead of true it can also be a list of languages - additional_vim_regex_highlighting = false, - }, - indent = { - enable = true, - disable = { "yaml" }, - }, }) diff --git a/after/plugin/trouble.lua b/after/plugin/trouble.lua deleted file mode 100644 index 6a8ec12..0000000 --- a/after/plugin/trouble.lua +++ /dev/null @@ -1,6 +0,0 @@ -local trouble = require('trouble') - -vim.keymap.set('n', 'tt', ':TodoTrouble') -vim.keymap.set('n', 'tv', function () - trouble.open() -end) diff --git a/after/plugin/undotree.lua b/after/plugin/undotree.lua deleted file mode 100755 index a346462..0000000 --- a/after/plugin/undotree.lua +++ /dev/null @@ -1 +0,0 @@ -vim.keymap.set('n', 'u', vim.cmd.UndotreeToggle) diff --git a/lua/409/plugins/comments.lua b/lua/409/plugins/comments.lua index a438e16..e83370b 100644 --- a/lua/409/plugins/comments.lua +++ b/lua/409/plugins/comments.lua @@ -59,5 +59,8 @@ return { "folke/todo-comments.nvim", event = "VeryLazy", dependencies = { "nvim-lua/plenary.nvim" }, + config = function () + require("todo-comments").setup() + end }, } diff --git a/lua/409/plugins/completion.lua b/lua/409/plugins/completion.lua index 17fa135..fa767ab 100644 --- a/lua/409/plugins/completion.lua +++ b/lua/409/plugins/completion.lua @@ -1,10 +1,76 @@ return { - "hrsh7th/nvim-cmp", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-nvim-lsp-signature-help", - "hrsh7th/cmp-nvim-lua", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "hrsh7th/cmp-cmdline", - "L3MON4D3/LuaSnip", + { + "hrsh7th/nvim-cmp", + dependencies = { "onsails/lspkind.nvim" }, + opts = function() + local cmp = require("cmp") + local lspkind = require("lspkind") + local border = require('409.ui').border + + local cmp_select = { behavior = cmp.SelectBehavior.Select } + local winhighlight = "Normal:CmpPmenu,FloatBorder:CmpPmenuBorder,CursorLine:PmenuSel,Search:None" + + return { + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + sources = { + { name = "nvim_lsp" }, + { name = "path" }, + { name = "nvim_lsp_signature_help" }, + { name = "nvim_lua" }, + { name = "luasnip", keyword_length = 2 }, + { name = "buffer", keyword_length = 3 }, + }, + view = { + entries = "custom", + }, + completion = { + completeopt = "menuone,noselect,preview", + docs_initially_visible = true, + }, + window = { + documentation = { + border = border, + winhighlight = winhighlight, + }, + completion = { + border = border, + winhighlight = winhighlight, + }, + }, + + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + local kind = lspkind.cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item) + local strings = vim.split(kind.kind, "%s", { trimempty = true }) + kind.kind = " " .. (strings[1] or "") .. " " + kind.menu = " (" .. (strings[2] or "") .. ")" + + return kind + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item(cmp_select), + [""] = cmp.mapping.select_next_item(cmp_select), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.complete(), + [""] = nil, + [""] = nil, + }), + } + end + }, + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-nvim-lsp-signature-help", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "L3MON4D3/LuaSnip", } diff --git a/lua/409/plugins/diagnostics.lua b/lua/409/plugins/diagnostics.lua index 4d0538d..3bc2613 100644 --- a/lua/409/plugins/diagnostics.lua +++ b/lua/409/plugins/diagnostics.lua @@ -2,5 +2,17 @@ return { { "folke/trouble.nvim", dependencies = { "nvim-tree/nvim-web-devicons" }, + keys = { + { + "tt", + ":TodoTrouble", + desc = "Trouble (TODOs)", + }, + { + "tv", + ":Trouble", + desc = "Trouble", + }, + }, }, } diff --git a/lua/409/plugins/extras/init.lua b/lua/409/plugins/extras/init.lua index ffdf152..a2e6f27 100644 --- a/lua/409/plugins/extras/init.lua +++ b/lua/409/plugins/extras/init.lua @@ -1,9 +1,13 @@ return { - { - "akinsho/flutter-tools.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - "stevearc/dressing.nvim", -- optional for vim.ui.select - }, - }, + { + "akinsho/flutter-tools.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "stevearc/dressing.nvim", -- optional for vim.ui.select + }, + event = "VeryLazy", + config = function() + require("flutter-tools").setup({}) + end, + }, } diff --git a/lua/409/plugins/formatting.lua b/lua/409/plugins/formatting.lua index 13131b5..0b61f05 100644 --- a/lua/409/plugins/formatting.lua +++ b/lua/409/plugins/formatting.lua @@ -1,5 +1,35 @@ return { { "stevearc/conform.nvim", + opts = function() + return { + formatters_by_ft = { + lua = { "stylua" }, + c = { "clang_format" }, + cs = { "csharpier" }, + javascript = { { "prettierd", "prettier" } }, + rust = { "rustfmt" }, + dart = { "dart_format" }, + }, + } + end, + config = function(plugin, opts) + local conform = require("conform") + conform.setup(opts) + + conform.formatters.clang_format = { + args = { "--style", "{IndentWidth: 4, UseTab: Always, TabWidth: 4}" }, + } + + conform.formatters.rustfmt = { + args = { "--edition", "2021" }, + } + + vim.keymap.set("n", "f", function() + if not conform.format({ bufnr = vim.lsp.bufnr }) then + vim.lsp.buf.format() + end + end) + end, }, } diff --git a/lua/409/plugins/lsp.lua b/lua/409/plugins/lsp.lua index 6bebf5f..36bc06d 100644 --- a/lua/409/plugins/lsp.lua +++ b/lua/409/plugins/lsp.lua @@ -1,6 +1,6 @@ return { "onsails/lspkind.nvim", - { "williamboman/mason.nvim" }, + "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", "neovim/nvim-lspconfig", } diff --git a/lua/409/plugins/statusline.lua b/lua/409/plugins/statusline.lua index 0bb77fc..5297ba3 100644 --- a/lua/409/plugins/statusline.lua +++ b/lua/409/plugins/statusline.lua @@ -1,7 +1,96 @@ +local lualine_theme = function() + local colors = { + darkgray = "#181825", + gray = "#cdd6f4", + innerbg = nil, + outerbg = "#313244", + normal = "#89b4fa", + insert = "#a6e3a1", + visual = "#cdd6f4", + replace = "#f38ba8", + command = "#fab387", + } + return { + inactive = { + a = { fg = colors.gray, bg = colors.outerbg, gui = "bold" }, + b = { fg = colors.gray, bg = colors.outerbg }, + c = { fg = colors.gray, bg = colors.innerbg }, + }, + visual = { + a = { fg = colors.darkgray, bg = colors.visual, gui = "bold" }, + b = { fg = colors.gray, bg = colors.outerbg }, + c = { fg = colors.gray, bg = colors.innerbg }, + }, + replace = { + a = { fg = colors.darkgray, bg = colors.replace, gui = "bold" }, + b = { fg = colors.gray, bg = colors.outerbg }, + c = { fg = colors.gray, bg = colors.innerbg }, + }, + normal = { + a = { fg = colors.darkgray, bg = colors.normal, gui = "bold" }, + b = { fg = colors.gray, bg = colors.outerbg }, + c = { fg = colors.gray, bg = colors.innerbg }, + }, + insert = { + a = { fg = colors.darkgray, bg = colors.insert, gui = "bold" }, + b = { fg = colors.gray, bg = colors.outerbg }, + c = { fg = colors.gray, bg = colors.innerbg }, + }, + command = { + a = { fg = colors.darkgray, bg = colors.command, gui = "bold" }, + b = { fg = colors.gray, bg = colors.outerbg }, + c = { fg = colors.gray, bg = colors.innerbg }, + }, + } +end + return { { "nvim-lualine/lualine.nvim", dependencies = { "nvim-tree/nvim-web-devicons" }, + opts = { + options = { + icons_enabled = true, + theme = lualine_theme(), + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + disabled_filetypes = { + statusline = { "packer" }, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "branch", "diff", "diagnostics" }, + lualine_c = { "filename" }, + lualine_x = { "encoding", "fileformat", "filetype" }, + lualine_y = { "progress" }, + lualine_z = { "location" }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { "filename" }, + lualine_x = { "location" }, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {}, + }, + config = function(plugin, opts) + require("lualine").setup(opts) + end, }, { "utilyre/barbecue.nvim", @@ -10,5 +99,8 @@ return { "SmiteshP/nvim-navic", "nvim-tree/nvim-web-devicons", -- optional dependency }, + config = function() + require("barbecue").setup() + end, }, } diff --git a/lua/409/plugins/treesitter.lua b/lua/409/plugins/treesitter.lua index 5be6326..62730d0 100644 --- a/lua/409/plugins/treesitter.lua +++ b/lua/409/plugins/treesitter.lua @@ -1,9 +1,58 @@ return { - { - "nvim-treesitter/nvim-treesitter", - dependencies = { - "nvim-treesitter/nvim-tree-docs", - "JoosepAlviste/nvim-ts-context-commentstring", - } - }, + { + "nvim-treesitter/nvim-treesitter", + dependencies = { + "nvim-treesitter/nvim-tree-docs", + "JoosepAlviste/nvim-ts-context-commentstring", + }, + config = function() + require("nvim-treesitter.configs").setup({ + -- A list of parser names, or "all" (the five listed parsers should always be installed) + ensure_installed = { + "javascript", + "typescript", + "c", + "lua", + "vim", + "vimdoc", + "query", + "c_sharp", + "css", + "gitcommit", + "html", + "svelte", + "yaml", + "astro", + "toml", + "jsdoc", + "json", + }, + + tree_docs = { + enable = true, + }, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + + highlight = { + enable = true, + + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, + indent = { + enable = true, + disable = { "yaml" }, + }, + }) + end, + }, } diff --git a/lua/409/plugins/util.lua b/lua/409/plugins/util.lua index 2ea4d4e..0f2fecd 100644 --- a/lua/409/plugins/util.lua +++ b/lua/409/plugins/util.lua @@ -7,7 +7,15 @@ return { "christoomey/vim-tmux-navigator", lazy = false, }, - "mbbill/undotree", + { + "mbbill/undotree", + keys = { + { + "u", + ":UndotreeToggle", + } + } + }, "nvim-tree/nvim-web-devicons", { "RRethy/vim-illuminate",