From 063cf3c98b73ba31969508a74c3df89fb5fa2086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Wed, 18 Oct 2023 12:05:43 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20config(nvim):=20deleted=20?= =?UTF-8?q?all=20the=20copy=20pasted=20options=20that=20i=20didnt=20change?= =?UTF-8?q?d=20from=20plugins=20of=20lazyvim=20to=20avoid=20substitution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/nvim/lua/plugins/bufferline.lua | 32 ------- .config/nvim/lua/plugins/cmp.lua | 89 ++++++-------------- .config/nvim/lua/plugins/conform.lua | 19 +---- .config/nvim/lua/plugins/gitsigns.lua | 46 +++++----- .config/nvim/lua/plugins/lspconfig.lua | 61 -------------- .config/nvim/lua/plugins/lualine.lua | 89 -------------------- .config/nvim/lua/plugins/neo-tree.lua | 106 ------------------------ 7 files changed, 44 insertions(+), 398 deletions(-) diff --git a/.config/nvim/lua/plugins/bufferline.lua b/.config/nvim/lua/plugins/bufferline.lua index a3bc4577..053db93d 100644 --- a/.config/nvim/lua/plugins/bufferline.lua +++ b/.config/nvim/lua/plugins/bufferline.lua @@ -2,14 +2,6 @@ local macchiato = require("catppuccin.palettes").get_palette("macchiato") return { { "akinsho/bufferline.nvim", - event = "VeryLazy", - dependencies = { - "catppuccin", - }, - keys = { - { "bp", "BufferLineTogglePin", desc = "Toggle pin" }, - { "bP", "BufferLineGroupClose ungrouped", desc = "Delete non-pinned buffers" }, - }, opts = { highlights = require("catppuccin.groups.integrations.bufferline").get({ styles = { "italic", "bold" }, @@ -25,31 +17,7 @@ return { modified_icon = "", close_icon = "", color_icons = true, - close_command = function(n) - require("mini.bufremove").delete(n, false) - end, separator_style = "slope", - right_mouse_command = function(n) - require("mini.bufremove").delete(n, false) - end, - themable = true, - view = "multiwindow", - diagnostics = "nvim_lsp", - always_show_bufferline = false, - diagnostics_indicator = function(_, _, diag) - local icons = require("lazyvim.config").icons.diagnostics - local ret = (diag.error and icons.Error .. diag.error .. " " or "") - .. (diag.warning and icons.Warn .. diag.warning or "") - return vim.trim(ret) - end, - offsets = { - { - filetype = "neo-tree", - text = "Neo-tree", - highlight = "Directory", - text_align = "left", - }, - }, }, }, }, diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua index 4be29456..9309861c 100644 --- a/.config/nvim/lua/plugins/cmp.lua +++ b/.config/nvim/lua/plugins/cmp.lua @@ -1,71 +1,30 @@ +local cmp = require("cmp") + return { { "hrsh7th/nvim-cmp", - version = false, -- last release is way too old - event = "InsertEnter", - dependencies = { - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "saadparwaiz1/cmp_luasnip", + opts = { + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [""] = function(fallback) + cmp.abort() + fallback() + end, + }), + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, }, - opts = function() - vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) - local cmp = require("cmp") - local defaults = require("cmp.config.default")() - return { - completion = { - completeopt = "menu,menuone,noinsert", - }, - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - [""] = function(fallback) - cmp.abort() - fallback() - end, - }), - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "path" }, - }, { - { name = "buffer" }, - }), - formatting = { - format = function(_, item) - local icons = require("lazyvim.config").icons.kinds - if icons[item.kind] then - item.kind = icons[item.kind] .. item.kind - end - return item - end, - }, - experimental = { - ghost_text = { - hl_group = "CmpGhostText", - }, - }, - sorting = defaults.sorting, - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - } - end, }, } diff --git a/.config/nvim/lua/plugins/conform.lua b/.config/nvim/lua/plugins/conform.lua index 6a2e0121..a13ff34b 100644 --- a/.config/nvim/lua/plugins/conform.lua +++ b/.config/nvim/lua/plugins/conform.lua @@ -1,7 +1,6 @@ return { { "stevearc/conform.nvim", - dependencies = { "mason.nvim" }, keys = { { "cC", @@ -30,23 +29,7 @@ return { scss = { { "prettierd", "prettier", "stylelint" } }, less = { { "prettierd", "prettier", "stylelint" } }, markdown = { { "prettierd", "prettier" } }, - }, - -- LazyVim will merge the options you set here with builtin formatters. - -- You can also define any custom formatters here. - ---@type table - formatters = { - injected = { options = { ignore_errors = true } }, - -- -- Example of using dprint only when a dprint.json file is present - -- dprint = { - -- condition = function(ctx) - -- return vim.fs.find({ "dprint.json" }, { path = ctx.filename, upward = true })[1] - -- end, - -- }, - taplo = { - condition = function(ctx) - return vim.fs.find({ "Cargo.toml" }, { path = ctx.filename, upward = true })[1] - end, - }, + toml = { "taplo" }, }, }, }, diff --git a/.config/nvim/lua/plugins/gitsigns.lua b/.config/nvim/lua/plugins/gitsigns.lua index 406aa23d..f2cb89ec 100644 --- a/.config/nvim/lua/plugins/gitsigns.lua +++ b/.config/nvim/lua/plugins/gitsigns.lua @@ -1,35 +1,27 @@ return { - { - "lewis6991/gitsigns.nvim", - event = { "BufReadPre", "BufNewFile" }, - opts = { - signs = { - add = { text = "▎" }, - change = { text = "▎" }, - delete = { text = "" }, - topdelete = { text = "" }, - changedelete = { text = "▎" }, - untracked = { text = "▎" }, - }, - yadm = { enable = true }, - current_line_blame = true, - current_line_blame_opts = { - virt_text = true, - virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' - delay = 5, - ignore_whitespace = false, - }, + { + "lewis6991/gitsigns.nvim", + opts = { + yadm = { enable = true }, + current_line_blame = true, + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' + delay = 5, + ignore_whitespace = false, + }, - on_attach = function(buffer) - local gs = package.loaded.gitsigns + on_attach = function(buffer) + local gs = package.loaded.gitsigns - local function map(mode, l, r, desc) - vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc }) - end + local function map(mode, l, r, desc) + vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc }) + end -- stylua: ignore start map("n", "]h", gs.next_hunk, "Next Hunk") map("n", "[h", gs.prev_hunk, "Prev Hunk") + map("n", "ub", "Gitsigns toggle_current_line_blame", "Toggle Line Blame") map({ "n", "v" }, "ghs", ":Gitsigns stage_hunk", "Stage Hunk") map({ "n", "v" }, "ghr", ":Gitsigns reset_hunk", "Reset Hunk") map("n", "ghS", gs.stage_buffer, "Stage Buffer") @@ -40,7 +32,7 @@ return { map("n", "ghd", gs.diffthis, "Diff This") map("n", "ghD", function() gs.diffthis("~") end, "Diff This ~") map({ "o", "x" }, "ih", ":Gitsigns select_hunk", "GitSigns Select Hunk") - end, - }, + end, }, + }, } diff --git a/.config/nvim/lua/plugins/lspconfig.lua b/.config/nvim/lua/plugins/lspconfig.lua index 687c4d90..3235391d 100644 --- a/.config/nvim/lua/plugins/lspconfig.lua +++ b/.config/nvim/lua/plugins/lspconfig.lua @@ -12,15 +12,7 @@ return { opts = { -- options for vim.diagnostic.config() diagnostics = { - underline = true, - update_in_insert = false, virtual_text = { - spacing = 4, - source = "if_many", - prefix = "●", - -- this will set set the prefix to a function that returns the diagnostics icon based on the severity - -- this only works on a recent 0.10.0 build. Will be set to "●" when not supported - -- prefix = "icons", float = { border = { { "┌", "FloatBorder" }, @@ -34,59 +26,6 @@ return { }, }, }, - severity_sort = true, - }, - -- Enable this to enable the builtin LSP inlay hints on Neovim >= 0.10.0 - -- Be aware that you also will need to properly configure your LSP server to - -- provide the inlay hints. - inlay_hints = { - enabled = false, - }, - -- add any global capabilities here - capabilities = {}, - -- Enable this to show formatters used in a notification - -- Useful for debugging formatter issues - format_notify = false, - -- options for vim.lsp.buf.format - -- `bufnr` and `filter` is handled by the LazyVim formatter, - -- but can be also overridden when specified - format = { - formatting_options = nil, - timeout_ms = nil, - }, - -- LSP Server Settings - ---@type lspconfig.options - servers = { - jsonls = {}, - lua_ls = { - -- mason = false, -- set to false if you don't want this server to be installed with mason - -- Use this to add any additional keymaps - -- for specific lsp servers - ---@type LazyKeys[] - -- keys = {}, - settings = { - Lua = { - workspace = { - checkThirdParty = false, - }, - completion = { - callSnippet = "Replace", - }, - }, - }, - }, - }, - -- you can do any additional lsp server setup here - -- return true if you don't want this server to be setup with lspconfig - ---@type table - setup = { - -- example to setup with typescript.nvim - -- tsserver = function(_, opts) - -- require("typescript").setup({ server = opts }) - -- return true - -- end, - -- Specify * to use this function as a fallback for any server - -- ["*"] = function(server, opts) end, }, }, }, diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua index f5762e57..f15ee9b1 100644 --- a/.config/nvim/lua/plugins/lualine.lua +++ b/.config/nvim/lua/plugins/lualine.lua @@ -1,27 +1,7 @@ return { { "nvim-lualine/lualine.nvim", - event = "VeryLazy", - init = function() - vim.g.lualine_laststatus = vim.o.laststatus - if vim.fn.argc(-1) > 0 then - -- set an empty statusline till lualine loads - vim.o.statusline = " " - else - -- hide the statusline on the starter page - vim.o.laststatus = 0 - end - end, opts = function() - -- PERF: we don't need this lualine require madness 🤷 - local lualine_require = require("lualine_require") - lualine_require.require = require - - local icons = require("lazyvim.config").icons - local Util = require("lazyvim.util") - - vim.o.laststatus = vim.g.lualine_laststatus - return { options = { theme = "catppuccin", @@ -31,74 +11,6 @@ return { section_separators = { left = "", right = "" }, }, sections = { - lualine_a = { "mode" }, - lualine_b = { "branch" }, - lualine_c = { - Util.lualine.root_dir(), - { - "diagnostics", - symbols = { - error = icons.diagnostics.Error, - warn = icons.diagnostics.Warn, - info = icons.diagnostics.Info, - hint = icons.diagnostics.Hint, - }, - }, - { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, - { - Util.lualine.pretty_path(), - }, --- stylua: ignore - { - function() - local ok, m = pcall(require, "better_escape") - return ok and m.waiting and "✺" or "" - end, - }, - }, - lualine_x = { - -- stylua: ignore - { - function() return require("noice").api.status.command.get() end, - cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end, - color = Util.ui.fg("Statement"), - }, - -- stylua: ignore - { - function() return require("noice").api.status.mode.get() end, - cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end, - color = Util.ui.fg("Constant"), - }, - -- stylua: ignore - { - function() return " " .. require("dap").status() end, - cond = function () return package.loaded["dap"] and require("dap").status() ~= "" end, - color = Util.ui.fg("Debug"), - }, - { - require("lazy.status").updates, - cond = require("lazy.status").has_updates, - color = Util.ui.fg("Special"), - }, - { - "diff", - symbols = { - added = icons.git.added, - modified = icons.git.modified, - removed = icons.git.removed, - }, - source = function() - local gitsigns = vim.b.gitsigns_status_dict - if gitsigns then - return { - added = gitsigns.added, - modified = gitsigns.changed, - removed = gitsigns.removed, - } - end - end, - }, - }, lualine_y = { { "progress", separator = " ", padding = { left = 1, right = 1 } }, }, @@ -106,7 +18,6 @@ return { { "location", padding = { left = 1, right = 1 } }, }, }, - extensions = { "neo-tree", "lazy" }, } end, }, diff --git a/.config/nvim/lua/plugins/neo-tree.lua b/.config/nvim/lua/plugins/neo-tree.lua index 6634528b..389031ee 100644 --- a/.config/nvim/lua/plugins/neo-tree.lua +++ b/.config/nvim/lua/plugins/neo-tree.lua @@ -1,118 +1,12 @@ -local Util = require("lazyvim.util") - return { { "nvim-neo-tree/neo-tree.nvim", - branch = "v3.x", - cmd = "Neotree", - keys = { - { - "fe", - function() - require("neo-tree.command").execute({ toggle = true, dir = Util.root() }) - end, - desc = "Explorer NeoTree (root dir)", - }, - { - "fE", - function() - require("neo-tree.command").execute({ toggle = true, dir = vim.loop.cwd() }) - end, - desc = "Explorer NeoTree (cwd)", - }, - { "e", "fe", desc = "Explorer NeoTree (root dir)", remap = true }, - { "E", "fE", desc = "Explorer NeoTree (cwd)", remap = true }, - { - "ge", - function() - require("neo-tree.command").execute({ source = "git_status", toggle = true }) - end, - desc = "Git explorer", - }, - { - "be", - function() - require("neo-tree.command").execute({ source = "buffers", toggle = true }) - end, - desc = "Buffer explorer", - }, - }, - deactivate = function() - vim.cmd([[Neotree close]]) - end, - init = function() - if vim.fn.argc() == 1 then - local stat = vim.loop.fs_stat(vim.fn.argv(0)) - if stat and stat.type == "directory" then - require("neo-tree") - end - end - end, opts = { - sources = { "filesystem", "git_status", "buffers", "document_symbols" }, - -- source_selector = { - -- winbar = true, - -- statusline = true, - -- }, - open_files_do_not_replace_types = { "terminal", "Trouble", "qf", "Outline" }, - enable_git_status = true, - enable_diagnostics = true, - filesystem = { - bind_to_cwd = false, - follow_current_file = { enabled = true }, - use_libuv_file_watcher = true, - }, window = { mappings = { - [""] = "none", ["e"] = "open", }, }, - default_component_configs = { - indent = { - with_expanders = true, -- if nil and file nesting is enabled, will enable expanders - expander_collapsed = "", - expander_expanded = "", - expander_highlight = "NeoTreeExpander", - }, - }, }, - config = function(_, opts) - opts.event_handlers = opts.event_handlers or {} - - local function on_move(data) - local clients = vim.lsp.get_active_clients() - for _, client in ipairs(clients) do - if client:supports_method("workspace/willRenameFiles") then - local resp = client.request_sync("workspace/willRenameFiles", { - files = { - { - oldUri = vim.uri_from_fname(data.source), - newUri = vim.uri_from_fname(data.destination), - }, - }, - }, 1000) - if resp and resp.result ~= nil then - vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding) - end - end - end - end - - local events = require("neo-tree.events") - vim.list_extend(opts.event_handlers, { - { event = events.FILE_MOVED, handler = on_move }, - { event = events.FILE_RENAMED, handler = on_move }, - }) - require("neo-tree").setup(opts) - vim.api.nvim_create_autocmd("TermClose", { - pattern = "*lazygit", - callback = function() - if package.loaded["neo-tree.sources.git_status"] then - require("neo-tree.sources.git_status").refresh() - end - end, - }) - end, }, }