From 97a0d6f17390ab7a4c9861a4dc5121fb9be940a7 Mon Sep 17 00:00:00 2001 From: servostar Date: Tue, 2 Jan 2024 23:44:49 +0100 Subject: [PATCH 1/8] added Nvimtree back in --- lua/core/options.lua | 2 +- lua/plugins/aerial.lua | 49 ++------- lua/plugins/cmp.lua | 86 ++++++++++++++++ lua/plugins/cokeline.lua | 56 +++------- lua/plugins/lspconfig.lua | 177 ++++++++++++++++++++++++++++++++ lua/plugins/lualine.lua | 12 +-- lua/plugins/mini.lua | 10 ++ lua/plugins/nvim-scrollview.lua | 4 +- lua/plugins/nvim-tree.lua | 41 ++++++++ lua/plugins/nvim-ufo.lua | 4 +- lua/plugins/telescope.lua | 12 ++- lua/plugins/tokyonight.lua | 4 +- lua/plugins/trouble.lua | 4 +- 13 files changed, 363 insertions(+), 98 deletions(-) create mode 100644 lua/plugins/cmp.lua create mode 100644 lua/plugins/lspconfig.lua create mode 100644 lua/plugins/mini.lua create mode 100644 lua/plugins/nvim-tree.lua diff --git a/lua/core/options.lua b/lua/core/options.lua index e855e72..d97d0b0 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -17,7 +17,7 @@ opt.laststatus = 3 -- global statusline opt.list = true -- Show some invisible characters (tabs... opt.mouse = "a" -- Enable mouse mode opt.number = true -- Print line number -opt.pumblend = 10 -- Popup blend +opt.pumblend = 0 -- Popup blend opt.pumheight = 10 -- Maximum number of entries in a popup opt.relativenumber = false -- Relative line numbers opt.scrolloff = 4 -- Lines of context diff --git a/lua/plugins/aerial.lua b/lua/plugins/aerial.lua index e81bb8b..e020877 100644 --- a/lua/plugins/aerial.lua +++ b/lua/plugins/aerial.lua @@ -1,42 +1,15 @@ return { - { - "stevearc/aerial.nvim", - opts = { - backends = { - "treesitter", - "lsp", - "markdown", - "man", - }, - layout = { - default_direction = "prefer_right", - placement = "edge", - resize_to_content = true, - preserve_equality = true, - }, - -- Disable aerial on files with this many lines - disable_max_lines = 10000, - -- Disable aerial on files this size or larger (in bytes) - disable_max_size = 2000000, -- Default 2MB - filter_kind = false, - highlight_on_hover = true, - nerd_font = "auto", - update_events = "TextChanged,InsertLeave", - show_guides = true, - autojump = true, - guides = { - -- When the child item has a sibling below it - mid_item = "│ ", - -- When the child item is the last in the list - last_item = "└ ", - -- When there are nested child guides to the right - nested_top = "│ ", - -- Raw indentation - whitespace = " ", - }, - lsp = { - diagnostics_trigger_update = true, - update_when_errors = true, + "stevearc/aerial.nvim", + opts = { + attach_mode = "global", + backends = { "lsp", "treesitter", "markdown", "man" }, + show_guides = false, + layout = { + resize_to_content = false, + win_opts = { + winhl = "Normal:NormalFloat,FloatBorder:NormalFloat,SignColumn:SignColumnSB", + signcolumn = "yes", + statuscolumn = " ", }, } } diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..5789a27 --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,86 @@ +return { + { + "hrsh7th/nvim-cmp", + opts = function() + vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) + local cmp = require("cmp") + local defaults = require("cmp.config.default")() + return { + window = { + completion = { + border = "rounded", + scrollbar = false, + winhighlight = "Normal:CmpPmenu,FloatBorder:CmpPmenu,Search:None" + }, + documentation = { + border = "rounded", + scrollbar = false, + winhighlight = "Normal:CmpPmenu,FloatBorder:CmpPmenu,Search:None" + }, + }, + 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 = 'nvim_lsp_signature_help' }, + { name = "luasnip" }, + { name = "path" }, + }, { + { name = "buffer" }, + }), + formatting = { + fields = { + "kind", + "abbr", + "menu" + }, + format = function(_, item) + item.menu = item.kind + local icons = require("lazyvim.config").icons.kinds + if icons[item.kind] then + item.kind = icons[item.kind] + end + return item + end, + }, + experimental = { + ghost_text = { + hl_group = "CmpGhostText", + } + }, + sorting = defaults.sorting, + } + end, + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-path", + "hrsh7th/cmp-nvim-lsp-signature-help", + "saadparwaiz1/cmp_luasnip", + } + } +} diff --git a/lua/plugins/cokeline.lua b/lua/plugins/cokeline.lua index 9d4b5ef..691ba3e 100644 --- a/lua/plugins/cokeline.lua +++ b/lua/plugins/cokeline.lua @@ -16,7 +16,7 @@ return { if buffer.is_focused then return "Normal" end - return "ColorColumn" + return "TabLine" end, fg = function(buffer) if buffer.is_focused then @@ -32,19 +32,12 @@ return { { text = function(buffer) if buffer.is_focused then - return "▎" + return "" end return " " end, fg = "Normal" }, - { - text = function(buffer) return buffer.devicon.icon end, - fg = function(buffer) return buffer.devicon.color end, - }, - { - text = function(buffer) return ' ' .. buffer.filename .. ' ' end, - }, { text = function(buffer) if buffer.is_modified then @@ -52,10 +45,17 @@ return { elseif buffer.is_readonly then return ' ' else - return '' + return ' ' end end }, + { + text = function(buffer) return buffer.devicon.icon end, + fg = function(buffer) return buffer.devicon.color end, + }, + { + text = function(buffer) return ' ' .. buffer.filename .. ' ' end, + }, { text = '󰅖', on_click = function(_, _, _, _, buffer) @@ -75,49 +75,25 @@ return { end, bg = function(tabpage) if tabpage.is_active then - return "TabLineSel" + return "NormalNC" end - return "ColorColumn" + return "TabLine" end, fg = function(tabpage) if tabpage.is_active then - return "TabLine" + return "NormalNC" end - return "Normal" + return "TabLine" end, bold = true }, - { - text = function(tabpage) - if tabpage.is_active then - return "󰅖 " - end - return "" - end, - on_click = function(_, _, _, _, tabpage) - tabpage:close() - end, - bg = function(tabpage) - if tabpage.is_active then - return "TabLineSel" - end - return "ColorColumn" - end, - fg = function(tabpage) - if tabpage.is_active then - return "TabLine" - end - return "Normal" - end, - bold = true - }, - } + }, }, sidebar = { filetype = { "NvimTree", "neo-tree", "SidebarNvim" }, components = { { - text = "Explorer", + text = "", bg = "ColorColumn" } }, diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua new file mode 100644 index 0000000..015af98 --- /dev/null +++ b/lua/plugins/lspconfig.lua @@ -0,0 +1,177 @@ +return { + { + "neovim/nvim-lspconfig", + dependencies = { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim" + }, + ---@class PluginLspOpts + opts = { + -- options for vim.diagnostic.config() + diagnostics = { + underline = true, + update_in_insert = true, + 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", + }, + severity_sort = true, + float = { + border = "rounded" + } + }, + -- 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 = {}, + -- 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, + }, + servers = { + lua_ls = { + mason = false + }, + rust_analyzer = { + mason = false + }, + }, + setup = { + } + }, + ---@param opts PluginLspOpts + config = function(_, opts) + local Util = require("lazyvim.util") + if Util.has("neoconf.nvim") then + local plugin = require("lazy.core.config").spec.plugins["neoconf.nvim"] + require("neoconf").setup(require("lazy.core.plugin").values(plugin, "opts", false)) + end + + -- setup autoformat + Util.format.register(Util.lsp.formatter()) + + -- deprectaed options + if opts.autoformat ~= nil then + vim.g.autoformat = opts.autoformat + Util.deprecate("nvim-lspconfig.opts.autoformat", "vim.g.autoformat") + end + + -- setup keymaps + Util.lsp.on_attach(function(client, buffer) + require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer) + end) + + local register_capability = vim.lsp.handlers["client/registerCapability"] + + vim.lsp.handlers["client/registerCapability"] = function(err, res, ctx) + local ret = register_capability(err, res, ctx) + local client_id = ctx.client_id + ---@type lsp.Client + local client = vim.lsp.get_client_by_id(client_id) + local buffer = vim.api.nvim_get_current_buf() + require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer) + return ret + end + + -- diagnostics + for name, icon in pairs(require("lazyvim.config").icons.diagnostics) do + name = "DiagnosticSign" .. name + vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" }) + end + + local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint + + if opts.inlay_hints.enabled and inlay_hint then + Util.lsp.on_attach(function(client, buffer) + if client.supports_method("textDocument/inlayHint") then + inlay_hint(buffer, true) + end + end) + end + + if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then + opts.diagnostics.virtual_text.prefix = vim.fn.has("nvim-0.10.0") == 0 and "●" + or function(diagnostic) + local icons = require("lazyvim.config").icons.diagnostics + for d, icon in pairs(icons) do + if diagnostic.severity == vim.diagnostic.severity[d:upper()] then + return icon + end + end + end + end + + vim.diagnostic.config(vim.deepcopy(opts.diagnostics)) + + local servers = opts.servers + local has_cmp, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") + local capabilities = vim.tbl_deep_extend( + "force", + {}, + vim.lsp.protocol.make_client_capabilities(), + has_cmp and cmp_nvim_lsp.default_capabilities() or {}, + opts.capabilities or {} + ) + + local function setup(server) + local server_opts = vim.tbl_deep_extend("force", { + capabilities = vim.deepcopy(capabilities), + }, servers[server] or {}) + + if opts.setup[server] then + if opts.setup[server](server, server_opts) then + return + end + elseif opts.setup["*"] then + if opts.setup["*"](server, server_opts) then + return + end + end + require("lspconfig")[server].setup(server_opts) + end + + -- get all the servers that are available through mason-lspconfig + local have_mason, mlsp = pcall(require, "mason-lspconfig") + local all_mslp_servers = {} + if have_mason then + all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package) + end + + local ensure_installed = {} ---@type string[] + for server, server_opts in pairs(servers) do + if server_opts then + server_opts = server_opts == true and {} or server_opts + -- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig + if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then + setup(server) + else + ensure_installed[#ensure_installed + 1] = server + end + end + end + + if have_mason then + mlsp.setup({ ensure_installed = ensure_installed, handlers = { setup } }) + end + + if Util.lsp.get_config("denols") and Util.lsp.get_config("tsserver") then + local is_deno = require("lspconfig.util").root_pattern("deno.json", "deno.jsonc") + Util.lsp.disable("tsserver", is_deno) + Util.lsp.disable("denols", function(root_dir) + return not is_deno(root_dir) + end) + end + end, + } +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua index 0500bb5..b503a67 100644 --- a/lua/plugins/lualine.lua +++ b/lua/plugins/lualine.lua @@ -5,7 +5,7 @@ return { "nvim-lualine/lualine.nvim", opts = { options = { - theme = 'tokyonight', + theme = 'auto', icons_enabled = true, globalstatus = true, section_separators = { left = '', right = '' }, @@ -15,16 +15,6 @@ return { 'help', 'startify', 'dashboard', - 'packer', - 'neogitstatus', - -- 'NvimTree', - 'Trouble', - 'alpha', - 'lir', - 'Outline', - 'neo-tree', - 'spectre_panel', - 'toggleterm', 'qf', }, winbar = { diff --git a/lua/plugins/mini.lua b/lua/plugins/mini.lua new file mode 100644 index 0000000..7b11147 --- /dev/null +++ b/lua/plugins/mini.lua @@ -0,0 +1,10 @@ +return { + { + 'echasnovski/mini.nvim', + version = '*', + config = function() + require("mini.pairs").setup() + require("mini.clue").setup() + end + }, +} diff --git a/lua/plugins/nvim-scrollview.lua b/lua/plugins/nvim-scrollview.lua index 79ac62d..a13cd36 100644 --- a/lua/plugins/nvim-scrollview.lua +++ b/lua/plugins/nvim-scrollview.lua @@ -3,7 +3,9 @@ return { "dstein64/nvim-scrollview", opts = { excluded_filetypes = { - 'dashboard' + 'dashboard', + 'neo-tree', + 'aerial' }, signs_on_startup = { 'conflicts', diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua new file mode 100644 index 0000000..9cad46d --- /dev/null +++ b/lua/plugins/nvim-tree.lua @@ -0,0 +1,41 @@ +return { + { + "nvim-tree/nvim-tree.lua", + opts = { + hijack_cursor = true, + sync_root_with_cwd = true, + renderer = { + indent_markers = { + enable = false + }, + icons = { + show = { + file = true, + folder = true, + folder_arrow = true, + git = true, + }, + } + }, + diagnostics = { + enable = true, + show_on_dirs = false, + }, + actions = { + change_dir = { + enable = false, + restrict_above_cwd = true, + }, + open_file = { + resize_window = false, + window_picker = { + chars = "aoeui", + }, + }, + remove_file = { + close_window = false, + }, + }, + } + } +} diff --git a/lua/plugins/nvim-ufo.lua b/lua/plugins/nvim-ufo.lua index da4e99a..469c7ce 100644 --- a/lua/plugins/nvim-ufo.lua +++ b/lua/plugins/nvim-ufo.lua @@ -17,8 +17,8 @@ return { }, }, -- register treesitter as source for scopes - provider_selector = function(bufnr, filetype, buftype) - return {'treesitter', 'indent'} + provider_selector = function(_, _, _) + return { 'treesitter', 'indent' } end } } diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 7f6b1a6..4958c8b 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -8,6 +8,16 @@ return { sorting_strategy = "ascending", winblend = 0, }, + extensions = { + aerial = { + -- Display symbols as .. + show_nesting = { + ["_"] = false, -- This key will be the default + json = true, -- You can set the option for specific filetypes + yaml = true, + }, + }, + }, }, dependencies = { "sharkdp/fd", @@ -15,4 +25,4 @@ return { 'nvim-tree/nvim-web-devicons' }, }, -} \ No newline at end of file +} diff --git a/lua/plugins/tokyonight.lua b/lua/plugins/tokyonight.lua index 6d79c71..d88fced 100644 --- a/lua/plugins/tokyonight.lua +++ b/lua/plugins/tokyonight.lua @@ -1,7 +1,7 @@ return { { "folke/tokyonight.nvim", - lazy = false, + lazy = true, priority = 1000, opts = { style = "night", @@ -10,7 +10,7 @@ return { sidebars = "dark", floats = "normal", }, - sidebars = { "qf", "help", "neo-tree", "aerial" }, + sidebars = { "qf", "trouble", "neo-tree", "aerial", "help" }, }, }, -- Configure LazyVim to load tokyonight diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua index 5a25a61..1a0ebad 100644 --- a/lua/plugins/trouble.lua +++ b/lua/plugins/trouble.lua @@ -2,8 +2,8 @@ return { { "folke/trouble.nvim", opts = { - use_diagnostic_signs = true + use_diagnostic_signs = true, + indent_lines = false, }, } } - From b213dd473101eac384f6f0926a58e21633d60076 Mon Sep 17 00:00:00 2001 From: servostar Date: Tue, 2 Jan 2024 23:45:51 +0100 Subject: [PATCH 2/8] removed unused plugins --- lua/plugins/mini-bufremove.lua | 5 - lua/plugins/neo-tree.lua | 65 ------------- lua/plugins/nvim-cmp.lua | 75 --------------- lua/plugins/nvim-lspconfig.lua | 170 --------------------------------- 4 files changed, 315 deletions(-) delete mode 100644 lua/plugins/mini-bufremove.lua delete mode 100644 lua/plugins/neo-tree.lua delete mode 100644 lua/plugins/nvim-cmp.lua delete mode 100644 lua/plugins/nvim-lspconfig.lua diff --git a/lua/plugins/mini-bufremove.lua b/lua/plugins/mini-bufremove.lua deleted file mode 100644 index 750b5a2..0000000 --- a/lua/plugins/mini-bufremove.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - { - "echasnovski/mini.bufremove", - }, -} \ No newline at end of file diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua deleted file mode 100644 index 9937a01..0000000 --- a/lua/plugins/neo-tree.lua +++ /dev/null @@ -1,65 +0,0 @@ -return { - { - "nvim-neo-tree/neo-tree.nvim", - branch = "v3.x", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - "MunifTanjim/nui.nvim", - -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information - }, - opts = { - popup_border_style = "rounded", - close_if_last_window = true, - enable_git_status = true, - enable_diagnostics = true, - open_files_do_not_replace_types = { "terminal", "trouble", "qf" }, -- when opening files, do not use windows containing these filetypes or buftypes - default_component_configs = { - indent = { - indent_size = 2, - padding = 1, -- extra padding on left hand side - -- indent guides - with_markers = true, - indent_marker = "│", - last_indent_marker = "└", - highlight = "NeoTreeIndentMarker", - -- expander config, needed for nesting files - with_expanders = true, -- if nil and file nesting is enabled, will enable expanders - expander_collapsed = "", - expander_expanded = "", - expander_highlight = "NeoTreeExpander", - }, - git_status = { - symbols = { - -- Change type - added = "+", -- or "✚", but this is redundant info if you use git_status_colors on the name - modified = "M", -- or "", but this is redundant info if you use git_status_colors on the name - deleted = "D", -- this can only be used in the git_status source - renamed = "󰁕", -- this can only be used in the git_status source - -- Status type - untracked = "", - ignored = "", - unstaged = "U", - staged = "S", - conflict = " ", - } - }, - modified = { - symbol = "+", - highlight = "NeoTreeModified", - }, - buffers = { - follow_current_file = { - enabled = true, - }, - }, - }, - filesystem = { - use_libuv_file_watcher = true, - follow_current_file = { - enabled = true - } - } - } - } -} diff --git a/lua/plugins/nvim-cmp.lua b/lua/plugins/nvim-cmp.lua deleted file mode 100644 index 3c83810..0000000 --- a/lua/plugins/nvim-cmp.lua +++ /dev/null @@ -1,75 +0,0 @@ -return { - { - "hrsh7th/nvim-cmp", - opts = function() - vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) - local cmp = require("cmp") - local defaults = require("cmp.config.default")() - return { - window = { - completion = { - border = "rounded", - scrollbar = false, - winhighlight = "Normal:CmpPmenu,FloatBorder:CmpPmenu,Search:None" - }, - documentation = { - border = "rounded", - scrollbar = false, - winhighlight = "Normal:CmpPmenu,FloatBorder:CmpPmenu,Search:None" - }, - }, - 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, - } - end, - dependencies = { - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - 'hrsh7th/cmp-cmdline', - "saadparwaiz1/cmp_luasnip", - } - } -} diff --git a/lua/plugins/nvim-lspconfig.lua b/lua/plugins/nvim-lspconfig.lua deleted file mode 100644 index 98e1d15..0000000 --- a/lua/plugins/nvim-lspconfig.lua +++ /dev/null @@ -1,170 +0,0 @@ -return { - { - "neovim/nvim-lspconfig", - dependencies = { - "williamboman/mason.nvim", - "williamboman/mason-lspconfig.nvim" - }, - ---@class PluginLspOpts - 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", - }, - severity_sort = true, - float = { - border = "rounded" - } - }, - -- 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 = {}, - -- 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, - }, - servers = require("core.language-server"), - setup = { - } - }, - ---@param opts PluginLspOpts - config = function(_, opts) - local Util = require("lazyvim.util") - if Util.has("neoconf.nvim") then - local plugin = require("lazy.core.config").spec.plugins["neoconf.nvim"] - require("neoconf").setup(require("lazy.core.plugin").values(plugin, "opts", false)) - end - - -- setup autoformat - Util.format.register(Util.lsp.formatter()) - - -- deprectaed options - if opts.autoformat ~= nil then - vim.g.autoformat = opts.autoformat - Util.deprecate("nvim-lspconfig.opts.autoformat", "vim.g.autoformat") - end - - -- setup keymaps - Util.lsp.on_attach(function(client, buffer) - require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer) - end) - - local register_capability = vim.lsp.handlers["client/registerCapability"] - - vim.lsp.handlers["client/registerCapability"] = function(err, res, ctx) - local ret = register_capability(err, res, ctx) - local client_id = ctx.client_id - ---@type lsp.Client - local client = vim.lsp.get_client_by_id(client_id) - local buffer = vim.api.nvim_get_current_buf() - require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer) - return ret - end - - -- diagnostics - for name, icon in pairs(require("lazyvim.config").icons.diagnostics) do - name = "DiagnosticSign" .. name - vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" }) - end - - local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint - - if opts.inlay_hints.enabled and inlay_hint then - Util.lsp.on_attach(function(client, buffer) - if client.supports_method("textDocument/inlayHint") then - inlay_hint(buffer, true) - end - end) - end - - if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then - opts.diagnostics.virtual_text.prefix = vim.fn.has("nvim-0.10.0") == 0 and "●" - or function(diagnostic) - local icons = require("lazyvim.config").icons.diagnostics - for d, icon in pairs(icons) do - if diagnostic.severity == vim.diagnostic.severity[d:upper()] then - return icon - end - end - end - end - - vim.diagnostic.config(vim.deepcopy(opts.diagnostics)) - - local servers = opts.servers - local has_cmp, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") - local capabilities = vim.tbl_deep_extend( - "force", - {}, - vim.lsp.protocol.make_client_capabilities(), - has_cmp and cmp_nvim_lsp.default_capabilities() or {}, - opts.capabilities or {} - ) - - local function setup(server) - local server_opts = vim.tbl_deep_extend("force", { - capabilities = vim.deepcopy(capabilities), - }, servers[server] or {}) - - if opts.setup[server] then - if opts.setup[server](server, server_opts) then - return - end - elseif opts.setup["*"] then - if opts.setup["*"](server, server_opts) then - return - end - end - require("lspconfig")[server].setup(server_opts) - end - - -- get all the servers that are available through mason-lspconfig - local have_mason, mlsp = pcall(require, "mason-lspconfig") - local all_mslp_servers = {} - if have_mason then - all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package) - end - - local ensure_installed = {} ---@type string[] - for server, server_opts in pairs(servers) do - if server_opts then - server_opts = server_opts == true and {} or server_opts - -- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig - if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then - setup(server) - else - ensure_installed[#ensure_installed + 1] = server - end - end - end - - if have_mason then - mlsp.setup({ ensure_installed = ensure_installed, handlers = { setup } }) - end - - if Util.lsp.get_config("denols") and Util.lsp.get_config("tsserver") then - local is_deno = require("lspconfig.util").root_pattern("deno.json", "deno.jsonc") - Util.lsp.disable("tsserver", is_deno) - Util.lsp.disable("denols", function(root_dir) - return not is_deno(root_dir) - end) - end - end, - } -} From a9b366459be38559bf3d0e489d29d3f6e77fadb6 Mon Sep 17 00:00:00 2001 From: servostar Date: Fri, 17 May 2024 10:33:26 +0200 Subject: [PATCH 3/8] added workflow and luacheckrc --- .gitea/workflows/luacheck.yml | 20 ++++++++++++++++++++ .luacheckrc | 4 ++++ 2 files changed, 24 insertions(+) create mode 100644 .gitea/workflows/luacheck.yml create mode 100644 .luacheckrc diff --git a/.gitea/workflows/luacheck.yml b/.gitea/workflows/luacheck.yml new file mode 100644 index 0000000..e558098 --- /dev/null +++ b/.gitea/workflows/luacheck.yml @@ -0,0 +1,20 @@ +name: Gitea Actions Demo +run-name: ${{ gitea.actor }} is performing luacheck +on: [push] + +jobs: + Explore-Gitea-Actions: + runs-on: ubuntu-latest + steps: + - run: echo "This job is now running on a ${{ runner.os }}" + - run: echo "The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." + - name: Check out repository code + uses: actions/checkout@v3 + - run: echo "The ${{ gitea.repository }} repository has been cloned to the runner." + - name: Install dependencies + run: apt update && apt install neovim python3 lua5.4 + - run: echo "The workflow is now ready to test your code on the runner." + - name: Luacheck linter + uses: lunarmodules/luacheck@v1 + - run: echo "This job's status is ${{ job.status }}." + diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..b69cbe1 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,4 @@ +color = true +globals = { + "vim" +} From d396f51ff3d60dbda5cdd1969a500215f9d60503 Mon Sep 17 00:00:00 2001 From: servostar Date: Fri, 17 May 2024 10:38:43 +0200 Subject: [PATCH 4/8] added -y option to apt --- .gitea/workflows/luacheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/luacheck.yml b/.gitea/workflows/luacheck.yml index e558098..8567754 100644 --- a/.gitea/workflows/luacheck.yml +++ b/.gitea/workflows/luacheck.yml @@ -12,7 +12,7 @@ jobs: uses: actions/checkout@v3 - run: echo "The ${{ gitea.repository }} repository has been cloned to the runner." - name: Install dependencies - run: apt update && apt install neovim python3 lua5.4 + run: apt update -y && apt install neovim python3 lua5.4 -y - run: echo "The workflow is now ready to test your code on the runner." - name: Luacheck linter uses: lunarmodules/luacheck@v1 From 62eb5491f3aaaebc181f3551415c594a206280f0 Mon Sep 17 00:00:00 2001 From: servostar Date: Fri, 17 May 2024 10:44:36 +0200 Subject: [PATCH 5/8] fixed luachecks --- lua/core/bootstrap.lua | 3 ++- lua/plugins/cmp.lua | 4 ++-- lua/plugins/lspconfig.lua | 4 ---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lua/core/bootstrap.lua b/lua/core/bootstrap.lua index c498b45..4654240 100644 --- a/lua/core/bootstrap.lua +++ b/lua/core/bootstrap.lua @@ -21,7 +21,8 @@ require("lazy").setup({ }, defaults = { -- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup. - -- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default. + -- If you know what you're doing, you can set this to `true` + -- to have all your custom plugins lazy-loaded by default. lazy = false, -- It's recommended to leave version=false for now, since a lot the plugin that support versioning, -- have outdated releases, which may break your Neovim install. diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 5789a27..a25e311 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -33,11 +33,11 @@ return { [""] = 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({ select = true }), [""] = 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() diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 015af98..4bf2a34 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -15,9 +15,6 @@ return { 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", }, severity_sort = true, float = { @@ -152,7 +149,6 @@ return { for server, server_opts in pairs(servers) do if server_opts then server_opts = server_opts == true and {} or server_opts - -- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then setup(server) else From 7572f5e22ab902383e9383f3c0d3f331ed85fc0c Mon Sep 17 00:00:00 2001 From: servostar Date: Wed, 4 Sep 2024 22:12:53 +0200 Subject: [PATCH 6/8] chore: added file .stow-global-ignore --- .stow-global-ignore | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .stow-global-ignore diff --git a/.stow-global-ignore b/.stow-global-ignore new file mode 100644 index 0000000..cdf2fd6 --- /dev/null +++ b/.stow-global-ignore @@ -0,0 +1,10 @@ +\.git +\.gitea +\.github +\.gitignore +\.stow-global-ignore +__pycache__ +^/README.* +^/LICENSE.* +^/COPYING + From 5c250543d566ea1f5f48f8c25102af64330158a7 Mon Sep 17 00:00:00 2001 From: servostar Date: Wed, 4 Sep 2024 22:27:27 +0200 Subject: [PATCH 7/8] chore: added script to setup config with stow --- run-stow.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 run-stow.sh diff --git a/run-stow.sh b/run-stow.sh new file mode 100755 index 0000000..c041c78 --- /dev/null +++ b/run-stow.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +NEOVIM_CONFIG="~/.config/nvim" + +if [ -d "$NEOVIM_CONFIG" ]; then + stow -v -R -t "$NEOVIM_CONFIG" . +else + echo "Neovim config directory does not exist: $NEOVIM_CONFIG" +fi + From 5ee96da76840b5c9b6bab471564df0ae735d3b4f Mon Sep 17 00:00:00 2001 From: servostar Date: Thu, 5 Sep 2024 18:14:39 +0200 Subject: [PATCH 8/8] bugfix: run-stow failing when config directory does not exist --- .stow-global-ignore | 4 +++- run-stow.sh | 22 ++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.stow-global-ignore b/.stow-global-ignore index cdf2fd6..83f71e6 100644 --- a/.stow-global-ignore +++ b/.stow-global-ignore @@ -7,4 +7,6 @@ __pycache__ ^/README.* ^/LICENSE.* ^/COPYING - +\.stow-global-ignore +\run-stow.sh +\setup-neovim.sh diff --git a/run-stow.sh b/run-stow.sh index c041c78..0fb1b3d 100755 --- a/run-stow.sh +++ b/run-stow.sh @@ -1,10 +1,20 @@ #!/bin/bash -NEOVIM_CONFIG="~/.config/nvim" +NEOVIM_CONFIG="$HOME/.config/nvim" -if [ -d "$NEOVIM_CONFIG" ]; then - stow -v -R -t "$NEOVIM_CONFIG" . -else - echo "Neovim config directory does not exist: $NEOVIM_CONFIG" -fi +function stowit() { + if test -d "$NEOVIM_CONFIG"; then + stow -v -R -t "$NEOVIM_CONFIG" . || exit 1 + else + echo "Neovim config directory does not exist: $NEOVIM_CONFIG" + echo "Creating config directory..." + if ! mkdir -p "$NEOVIM_CONFIG"; then + echo "failed to create config folder" + exit 1 + fi + echo "Created config folder" + stowit + fi +} +stowit