diff options
author | Abouzar Parvan <[email protected]> | 2022-09-20 14:11:58 +0430 |
---|---|---|
committer | GitHub <[email protected]> | 2022-09-20 14:11:58 +0430 |
commit | 518b1d4167162a54a6e76784038d30191613b76d (patch) | |
tree | 6007451a5e1f77db9ee116ee1a262c8f0639115d | |
parent | 03ec31253fc868b3ab5a8217640ec04248ae0046 (diff) |
Fix: make sure latest plugins are customizable (#3044)
* fix: make navim-navic configurable
* fix: make sure vim-illuminate is configurable
* fix: make sure theme is configurable
* fix(ci): don't verify uninstalled plugins
* refactor(lsp): add setup_document_symbols util
* revert: keep onedarker on freeze branch
* refactor(lsp): avoid duplicate hl autocmds
Co-authored-by: kylo252 <[email protected]>
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | lua/lvim/config/defaults.lua | 2 | ||||
-rw-r--r-- | lua/lvim/core/breadcrumbs.lua | 106 | ||||
-rw-r--r-- | lua/lvim/core/builtins/init.lua | 1 | ||||
-rw-r--r-- | lua/lvim/core/illuminate.lua | 98 | ||||
-rw-r--r-- | lua/lvim/core/theme.lua | 50 | ||||
-rw-r--r-- | lua/lvim/lsp/config.lua | 2 | ||||
-rw-r--r-- | lua/lvim/lsp/handlers.lua | 3 | ||||
-rw-r--r-- | lua/lvim/lsp/init.lua | 11 | ||||
-rw-r--r-- | lua/lvim/lsp/utils.lua | 18 | ||||
-rw-r--r-- | lua/lvim/plugins.lua | 30 | ||||
-rw-r--r-- | snapshots/default.json | 15 | ||||
-rw-r--r-- | utils/ci/verify_plugins.lua | 8 | ||||
-rw-r--r-- | utils/installer/config.example.lua | 7 | ||||
-rw-r--r-- | utils/installer/config_win.example.lua | 7 |
15 files changed, 231 insertions, 131 deletions
@@ -70,7 +70,7 @@ Example: ```lua -- general lvim.format_on_save = true -lvim.colorscheme = "onedarker" +lvim.colorscheme = "tokyonight" lvim.leader = "space" -- add your own keymapping @@ -125,7 +125,7 @@ linters.setup { -- Additional Plugins lvim.plugins = { {"lunarvim/colorschemes"}, - {"folke/tokyonight.nvim"}, { + { "ray-x/lsp_signature.nvim", config = function() require"lsp_signature".on_attach() end, event = "BufRead" diff --git a/lua/lvim/config/defaults.lua b/lua/lvim/config/defaults.lua index 7546644f..91bc1130 100644 --- a/lua/lvim/config/defaults.lua +++ b/lua/lvim/config/defaults.lua @@ -1,6 +1,6 @@ return { leader = "space", - colorscheme = "onedarker", + colorscheme = "tokyonight", transparent_window = false, format_on_save = { ---@usage pattern string pattern used for the autocommand (Default: '*') diff --git a/lua/lvim/core/breadcrumbs.lua b/lua/lvim/core/breadcrumbs.lua index 3b038473..9289cb03 100644 --- a/lua/lvim/core/breadcrumbs.lua +++ b/lua/lvim/core/breadcrumbs.lua @@ -3,60 +3,66 @@ local M = {} -- local Log = require "lvim.core.log" M.config = function() + lvim.builtin.breadcrumbs = { + active = false, + on_config_done = nil, + options = { + icons = { + 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 = " ", + Array = " ", + Number = " ", + String = " ", + Boolean = "蘒", + Object = " ", + Package = " ", + Namespace = "", + Key = "", + Null = "ﳠ", + }, + highlight = true, + separator = " " .. ">" .. " ", + depth_limit = 0, + depth_limit_indicator = "..", + }, + } +end + +M.setup = function() local status_ok, navic = pcall(require, "nvim-navic") if not status_ok then return end - navic.setup { - icons = { - Text = " ", - -- Method = "m", - -- Function = "", - -- Constructor = "", - Method = " ", - Function = " ", - Constructor = " ", - Field = " ", - -- Variable = "", - Variable = " ", - Class = " ", - Interface = " ", - -- Module = "", - Module = " ", - Property = " ", - Unit = " ", - Value = " ", - Enum = " ", - -- Keyword = "", - Keyword = " ", - -- Snippet = "", - Snippet = " ", - Color = " ", - File = " ", - Reference = " ", - Folder = " ", - EnumMember = " ", - Constant = " ", - Struct = " ", - Event = " ", - Operator = " ", - TypeParameter = " ", - Array = " ", - Number = " ", - String = " ", - Boolean = "蘒", - Object = " ", - Package = " ", - Namespace = "", - Key = "", - Null = "ﳠ", - }, - highlight = true, - separator = " " .. ">" .. " ", - depth_limit = 0, - depth_limit_indicator = "..", - } + M.create_winbar() + navic.setup(lvim.builtin.breadcrumbs.options) + + if lvim.builtin.breadcrumbs.on_config_done then + lvim.builtin.breadcrumbs.on_config_done() + end end M.winbar_filetype_exclude = { @@ -199,6 +205,4 @@ M.create_winbar = function() end end -M.create_winbar() - return M diff --git a/lua/lvim/core/builtins/init.lua b/lua/lvim/core/builtins/init.lua index 14afe4ea..36d09d2e 100644 --- a/lua/lvim/core/builtins/init.lua +++ b/lua/lvim/core/builtins/init.lua @@ -1,6 +1,7 @@ local M = {} local builtins = { + "lvim.core.theme", "lvim.core.which-key", "lvim.core.gitsigns", "lvim.core.cmp", diff --git a/lua/lvim/core/illuminate.lua b/lua/lvim/core/illuminate.lua index e29b091a..e0c8c775 100644 --- a/lua/lvim/core/illuminate.lua +++ b/lua/lvim/core/illuminate.lua @@ -1,53 +1,65 @@ local M = {} M.config = function() + lvim.builtin.illuminate = { + active = true, + on_config_done = nil, + options = { + -- providers: provider used to get references in the buffer, ordered by priority + providers = { + "lsp", + "treesitter", + "regex", + }, + -- delay: delay in milliseconds + delay = 120, + -- filetypes_denylist: filetypes to not illuminate, this overrides filetypes_allowlist + filetypes_denylist = { + "dirvish", + "fugitive", + "alpha", + "NvimTree", + "packer", + "neogitstatus", + "Trouble", + "lir", + "Outline", + "spectre_panel", + "toggleterm", + "DressingSelect", + "TelescopePrompt", + }, + -- filetypes_allowlist: filetypes to illuminate, this is overriden by filetypes_denylist + filetypes_allowlist = {}, + -- modes_denylist: modes to not illuminate, this overrides modes_allowlist + modes_denylist = {}, + -- modes_allowlist: modes to illuminate, this is overriden by modes_denylist + modes_allowlist = {}, + -- providers_regex_syntax_denylist: syntax to not illuminate, this overrides providers_regex_syntax_allowlist + -- Only applies to the 'regex' provider + -- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') + providers_regex_syntax_denylist = {}, + -- providers_regex_syntax_allowlist: syntax to illuminate, this is overriden by providers_regex_syntax_denylist + -- Only applies to the 'regex' provider + -- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') + providers_regex_syntax_allowlist = {}, + -- under_cursor: whether or not to illuminate under the cursor + under_cursor = true, + }, + } +end + +M.setup = function() local status_ok, illuminate = pcall(require, "illuminate") if not status_ok then return end - -- default configuration - illuminate.configure { - -- providers: provider used to get references in the buffer, ordered by priority - providers = { - "lsp", - "treesitter", - "regex", - }, - -- delay: delay in milliseconds - delay = 120, - -- filetypes_denylist: filetypes to not illuminate, this overrides filetypes_allowlist - filetypes_denylist = { - "dirvish", - "fugitive", - "alpha", - "NvimTree", - "packer", - "neogitstatus", - "Trouble", - "lir", - "Outline", - "spectre_panel", - "toggleterm", - "DressingSelect", - "TelescopePrompt", - }, - -- filetypes_allowlist: filetypes to illuminate, this is overriden by filetypes_denylist - filetypes_allowlist = {}, - -- modes_denylist: modes to not illuminate, this overrides modes_allowlist - modes_denylist = {}, - -- modes_allowlist: modes to illuminate, this is overriden by modes_denylist - modes_allowlist = {}, - -- providers_regex_syntax_denylist: syntax to not illuminate, this overrides providers_regex_syntax_allowlist - -- Only applies to the 'regex' provider - -- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') - providers_regex_syntax_denylist = {}, - -- providers_regex_syntax_allowlist: syntax to illuminate, this is overriden by providers_regex_syntax_denylist - -- Only applies to the 'regex' provider - -- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') - providers_regex_syntax_allowlist = {}, - -- under_cursor: whether or not to illuminate under the cursor - under_cursor = true, - } + + illuminate.configure(lvim.builtin.illuminate.options) + + if lvim.builtin.illuminate.on_config_done then + lvim.builtin.illuminate.on_config_done() + end end return M diff --git a/lua/lvim/core/theme.lua b/lua/lvim/core/theme.lua new file mode 100644 index 00000000..c02aaa7e --- /dev/null +++ b/lua/lvim/core/theme.lua @@ -0,0 +1,50 @@ +local M = {} + +M.config = function() + lvim.builtin.theme = { + name = "tokyonight", + options = { + style = "night", -- The theme comes in three styles, `storm`, a darker variant `night` and `day` + transparent = lvim.transparent_window, -- Enable this to disable setting the background color + terminal_colors = true, -- Configure the colors used when opening a `:terminal` in Neovim + styles = { + -- Style to be applied to different syntax groups + -- Value is any valid attr-list value for `:help nvim_set_hl` + comments = { italic = true }, + keywords = { italic = true }, + functions = {}, + variables = {}, + -- Background styles. Can be "dark", "transparent" or "normal" + sidebars = "dark", -- style for sidebars, see below + floats = "dark", -- style for floating windows + }, + -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]` + sidebars = { + "qf", + "vista_kind", + "terminal", + "packer", + "spectre_panel", + "NeogitStatus", + "help", + }, + day_brightness = 0.3, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors + hide_inactive_statusline = false, -- Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**. + dim_inactive = false, -- dims inactive windows + lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold + use_background = true, -- can be light/dark/auto. When auto, background will be set to vim.o.background + }, + } +end + +M.setup = function() + local status_ok, theme = pcall(require, "tokyonight") + if not status_ok then + return + end + + theme.setup(lvim.builtin.theme.options) + lvim.builtin.lualine.options.theme = "tokyonight" +end + +return M diff --git a/lua/lvim/lsp/config.lua b/lua/lvim/lsp/config.lua index 7e91db52..d842f099 100644 --- a/lua/lvim/lsp/config.lua +++ b/lua/lvim/lsp/config.lua @@ -72,7 +72,7 @@ return { end, }, }, - document_highlight = true, + document_highlight = false, code_lens_refresh = true, float = { focusable = true, diff --git a/lua/lvim/lsp/handlers.lua b/lua/lvim/lsp/handlers.lua index 45b1989d..81342885 100644 --- a/lua/lvim/lsp/handlers.lua +++ b/lua/lvim/lsp/handlers.lua @@ -12,6 +12,9 @@ function M.setup() float = lvim.lsp.diagnostics.float, } vim.diagnostic.config(config) + if not lvim.builtin.illuminate.active then + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, lvim.lsp.float) + end vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, lvim.lsp.float) end diff --git a/lua/lvim/lsp/init.lua b/lua/lvim/lsp/init.lua index ac3f6925..1072329b 100644 --- a/lua/lvim/lsp/init.lua +++ b/lua/lvim/lsp/init.lua @@ -60,15 +60,6 @@ function M.common_on_init(client, bufnr) end end -local function attach_navic(client, bufnr) - vim.g.navic_silence = true - local status_ok, navic = pcall(require, "nvim-navic") - if not status_ok then - return - end - navic.attach(client, bufnr) -end - function M.common_on_attach(client, bufnr) if lvim.lsp.on_attach_callback then lvim.lsp.on_attach_callback(client, bufnr) @@ -83,7 +74,7 @@ function M.common_on_attach(client, bufnr) end add_lsp_buffer_keybindings(bufnr) add_lsp_buffer_options(bufnr) - attach_navic(client, bufnr) + lu.setup_document_symbols(client, bufnr) end function M.get_common_opts() diff --git a/lua/lvim/lsp/utils.lua b/lua/lvim/lsp/utils.lua index 3be7e52f..c2ffe3fa 100644 --- a/lua/lvim/lsp/utils.lua +++ b/lua/lvim/lsp/utils.lua @@ -1,6 +1,7 @@ local M = {} local tbl = require "lvim.utils.table" +local Log = require "lvim.core.log" function M.is_client_active(name) local clients = vim.lsp.get_active_clients() @@ -82,6 +83,10 @@ function M.get_all_supported_filetypes() end function M.setup_document_highlight(client, bufnr) + if lvim.builtin.illuminate.active then + Log:debug "skipping setup for document_highlight, illuminate already active" + return + end local status_ok, highlight_supported = pcall(function() return client.supports_method "textDocument/documentHighlight" end) @@ -114,6 +119,19 @@ function M.setup_document_highlight(client, bufnr) }) end +function M.setup_document_symbols(client, bufnr) + vim.g.navic_silence = false -- can be set to true to supress error + local symbols_supported = client.supports_method "textDocument/documentSymbol" + if not symbols_supported then + Log:debug("skipping setup for document_symbols, method not supported by " .. client.name) + return + end + local status_ok, navic = pcall(require, "nvim-navic") + if status_ok then + navic.attach(client, bufnr) + end +end + function M.setup_codelens_refresh(client, bufnr) local status_ok, codelens_supported = pcall(function() return client.supports_method "textDocument/codeLens" diff --git a/lua/lvim/plugins.lua b/lua/lvim/plugins.lua index 85c1e80e..e84049dc 100644 --- a/lua/lvim/plugins.lua +++ b/lua/lvim/plugins.lua @@ -15,16 +15,11 @@ local core_plugins = { end, }, { - "lunarvim/tokyonight.nvim", + "folke/tokyonight.nvim", config = function() - pcall(function() - if lvim and lvim.colorscheme == "tokyonight-night" then - require("tokyonight-night").setup() - lvim.builtin.lualine.options.theme = "tokyonight-night" - end - end) + require("lvim.core.theme").setup() end, - disable = lvim.colorscheme ~= "tokyonight-night", + disable = not vim.startswith(lvim.colorscheme, "tokyonight"), }, { "rcarriga/nvim-notify", @@ -208,7 +203,7 @@ local core_plugins = { config = function() require("lvim.core.breadcrumbs").setup() end, - -- disable = not lvim.builtin.breadcrumbs.active, + disable = not lvim.builtin.breadcrumbs.active, }, { @@ -267,6 +262,23 @@ local core_plugins = { { "RRethy/vim-illuminate", + setup = function() + require("lvim.core.illuminate").setup() + end, + disable = not lvim.builtin.illuminate.active, + }, + { + "lunarvim/onedarker.nvim", + branch = "freeze", + config = function() + pcall(function() + if lvim and lvim.colorscheme == "onedarker" then + require("onedarker").setup() + lvim.builtin.lualine.options.theme = "onedarker" + end + end) + end, + disable = lvim.colorscheme ~= "onedarker", }, } diff --git a/snapshots/default.json b/snapshots/default.json index aae5e387..dc19f496 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -68,6 +68,9 @@ "nvim-lspconfig": { "commit": "f8b3c24" }, + "nvim-navic": { + "commit": "202312e" + }, "nvim-notify": { "commit": "7076ce8" }, @@ -83,8 +86,8 @@ "nvim-web-devicons": { "commit": "2d02a56" }, - "tokyonight.nvim": { - "commit": "4bd6ba8" + "onedarker.nvim": { + "commit": "b00dd21" }, "packer.nvim": { "commit": "6afb674" @@ -113,13 +116,13 @@ "toggleterm.nvim": { "commit": "5e393e5" }, - "which-key.nvim": { - "commit": "d5f0c63" + "tokyonight.nvim": { + "commit": "e0bdba5" }, "vim-illuminate": { "commit": "b545262" }, - "nvim-navic": { - "commit": "202312e" + "which-key.nvim": { + "commit": "d5f0c63" } } diff --git a/utils/ci/verify_plugins.lua b/utils/ci/verify_plugins.lua index 3cc5dd82..cecb01db 100644 --- a/utils/ci/verify_plugins.lua +++ b/utils/ci/verify_plugins.lua @@ -33,8 +33,7 @@ end local get_install_path = function(spec) local prefix = is_optional(spec) and packer_config.opt_dir or packer_config.start_dir local path = join_paths(prefix, get_short_name(spec)) - assert(is_directory(path)) - return path + return is_directory(path) and path end local function call_proc(process, opts, cb) @@ -92,11 +91,12 @@ end local function verify_core_plugins(verbose) for _, spec in pairs(core_plugins) do - if not spec.disable then + local path = get_install_path(spec) + if not spec.disable and path then table.insert(collection, { name = get_short_name(spec), commit = get_default_sha1(spec), - path = get_install_path(spec), + path = path, }) end end diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index f5d50709..8f490f77 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -11,7 +11,7 @@ an executable -- general lvim.log.level = "warn" lvim.format_on_save = true -lvim.colorscheme = "onedarker" +lvim.colorscheme = "tokyonight" -- to disable icons and use a minimalist setup, uncomment the following -- lvim.use_icons = false @@ -44,6 +44,10 @@ lvim.keys.normal_mode["<C-s>"] = ":w<cr>" -- }, -- } +-- Change theme settings +-- lvim.builtin.theme.options.dim_inactive = true +-- lvim.builtin.theme.options.style = "storm" + -- Use which-key to add extra bindings with the leader-key prefix -- lvim.builtin.which_key.mappings["P"] = { "<cmd>Telescope projects<CR>", "Projects" } -- lvim.builtin.which_key.mappings["t"] = { @@ -161,7 +165,6 @@ lvim.builtin.treesitter.highlight.enable = true -- Additional Plugins -- lvim.plugins = { --- {"folke/tokyonight.nvim"}, -- { -- "folke/trouble.nvim", -- cmd = "TroubleToggle", diff --git a/utils/installer/config_win.example.lua b/utils/installer/config_win.example.lua index 8fe03d69..bc83aab7 100644 --- a/utils/installer/config_win.example.lua +++ b/utils/installer/config_win.example.lua @@ -28,7 +28,7 @@ vim.g.clipboard = { -- general lvim.log.level = "warn" lvim.format_on_save = true -lvim.colorscheme = "onedarker" +lvim.colorscheme = "tokyonight" -- to disable icons and use a minimalist setup, uncomment the following -- lvim.use_icons = false @@ -61,6 +61,10 @@ lvim.keys.normal_mode["<C-s>"] = ":w<cr>" -- }, -- } +-- Change theme settings +-- lvim.builtin.theme.options.dim_inactive = true +-- lvim.builtin.theme.options.style = "storm" + -- Use which-key to add extra bindings with the leader-key prefix -- lvim.builtin.which_key.mappings["P"] = { "<cmd>Telescope projects<CR>", "Projects" } -- lvim.builtin.which_key.mappings["t"] = { @@ -176,7 +180,6 @@ lvim.builtin.treesitter.highlight.enable = true -- Additional Plugins -- lvim.plugins = { --- {"folke/tokyonight.nvim"}, -- { -- "folke/trouble.nvim", -- cmd = "TroubleToggle", |