diff options
Diffstat (limited to 'lua/lvim/core')
-rw-r--r-- | lua/lvim/core/autocmds.lua | 72 | ||||
-rw-r--r-- | lua/lvim/core/bufferline.lua | 9 | ||||
-rw-r--r-- | lua/lvim/core/cmp.lua | 6 | ||||
-rw-r--r-- | lua/lvim/core/dap.lua | 8 | ||||
-rw-r--r-- | lua/lvim/core/gitsigns.lua | 1 | ||||
-rw-r--r-- | lua/lvim/core/info.lua | 1 | ||||
-rw-r--r-- | lua/lvim/core/lualine/styles.lua | 6 | ||||
-rw-r--r-- | lua/lvim/core/notify.lua | 9 | ||||
-rw-r--r-- | lua/lvim/core/nvimtree.lua | 65 | ||||
-rw-r--r-- | lua/lvim/core/telescope.lua | 18 | ||||
-rw-r--r-- | lua/lvim/core/terminal.lua | 1 | ||||
-rw-r--r-- | lua/lvim/core/which-key.lua | 37 |
12 files changed, 123 insertions, 110 deletions
diff --git a/lua/lvim/core/autocmds.lua b/lua/lvim/core/autocmds.lua index e10a42db..17c9bc22 100644 --- a/lua/lvim/core/autocmds.lua +++ b/lua/lvim/core/autocmds.lua @@ -70,79 +70,44 @@ local get_format_on_save_opts = function() } end -function M.enable_format_on_save(opts) - local fmd_cmd = string.format(":silent lua vim.lsp.buf.formatting_sync({}, %s)", opts.timeout) - M.define_augroups { - format_on_save = { { "BufWritePre", opts.pattern, fmd_cmd } }, - } +function M.enable_format_on_save() + local opts = get_format_on_save_opts() + vim.api.nvim_create_augroup("lsp_format_on_save", {}) + vim.api.nvim_create_autocmd("BufWritePre", { + group = "lsp_format_on_save", + pattern = opts.pattern, + callback = function() + vim.lsp.buf.format { timeout_ms = opts.timeout, filter = opts.filter } + end, + }) Log:debug "enabled format-on-save" end function M.disable_format_on_save() - M.disable_augroup "format_on_save" + pcall(vim.api.nvim_del_augroup_by_name, "lsp_format_on_save") Log:debug "disabled format-on-save" end function M.configure_format_on_save() if lvim.format_on_save then - local opts = get_format_on_save_opts() - M.enable_format_on_save(opts) + M.enable_format_on_save() else M.disable_format_on_save() end end function M.toggle_format_on_save() - if vim.fn.exists "#format_on_save#BufWritePre" == 0 then - local opts = get_format_on_save_opts() - M.enable_format_on_save(opts) + local status, _ = pcall(vim.api.nvim_get_autocmds, { + group = "lsp_format_on_save", + event = "BufWritePre", + }) + if not status then + M.enable_format_on_save() else M.disable_format_on_save() end end -function M.enable_lsp_document_highlight(client_id) - M.define_augroups({ - lsp_document_highlight = { - { - "CursorHold", - "<buffer>", - string.format("lua require('lvim.lsp.utils').conditional_document_highlight(%d)", client_id), - }, - { - "CursorMoved", - "<buffer>", - "lua vim.lsp.buf.clear_references()", - }, - }, - }, true) -end - -function M.disable_lsp_document_highlight() - M.disable_augroup "lsp_document_highlight" -end - -function M.enable_code_lens_refresh() - M.define_augroups({ - lsp_code_lens_refresh = { - { - "InsertLeave ", - "<buffer>", - "lua vim.lsp.codelens.refresh()", - }, - { - "InsertLeave ", - "<buffer>", - "lua vim.lsp.codelens.display()", - }, - }, - }, true) -end - -function M.disable_code_lens_refresh() - M.disable_augroup "lsp_code_lens_refresh" -end - function M.enable_transparent_mode() vim.cmd "au ColorScheme * hi Normal ctermbg=none guibg=none" vim.cmd "au ColorScheme * hi SignColumn ctermbg=none guibg=none" @@ -170,7 +135,6 @@ end --- Create autocommand groups based on the passed definitions ---@param definitions table contains trigger, pattern and text. The key will be used as a group name ----@param buffer boolean indicate if the augroup should be local to the buffer function M.define_augroups(definitions, buffer) for group_name, definition in pairs(definitions) do vim.cmd("augroup " .. group_name) diff --git a/lua/lvim/core/bufferline.lua b/lua/lvim/core/bufferline.lua index d16c3d79..cb322032 100644 --- a/lua/lvim/core/bufferline.lua +++ b/lua/lvim/core/bufferline.lua @@ -4,9 +4,12 @@ local function is_ft(b, ft) return vim.bo[b].filetype == ft end -local function diagnostics_indicator(_, _, diagnostics) +local function diagnostics_indicator(num, _, diagnostics, _) local result = {} local symbols = { error = "", warning = "", info = "" } + if not lvim.use_icons then + return "(" .. num .. ")" + end for name, count in pairs(diagnostics) do if symbols[name] and count > 0 then table.insert(result, symbols[name] .. " " .. count) @@ -112,8 +115,8 @@ M.config = function() padding = 1, }, }, - show_buffer_icons = true, -- disable filetype icons for buffers - show_buffer_close_icons = true, + show_buffer_icons = lvim.use_icons, -- disable filetype icons for buffers + show_buffer_close_icons = lvim.use_icons, show_close_icon = false, show_tab_indicators = true, persist_buffer_sort = true, -- whether or not custom sorted buffers should persist diff --git a/lua/lvim/core/cmp.lua b/lua/lvim/core/cmp.lua index 4eff9883..baf6279b 100644 --- a/lua/lvim/core/cmp.lua +++ b/lua/lvim/core/cmp.lua @@ -207,6 +207,7 @@ M.config = function() vsnip = "(Snippet)", luasnip = "(Snippet)", buffer = "(Buffer)", + tmux = "(TMUX)", }, duplicates = { buffer = 1, @@ -220,7 +221,9 @@ M.config = function() if max_width ~= 0 and #vim_item.abbr > max_width then vim_item.abbr = string.sub(vim_item.abbr, 1, max_width - 1) .. "…" end - vim_item.kind = lvim.builtin.cmp.formatting.kind_icons[vim_item.kind] + if lvim.use_icons then + vim_item.kind = lvim.builtin.cmp.formatting.kind_icons[vim_item.kind] + end vim_item.menu = lvim.builtin.cmp.formatting.source_names[entry.source.name] vim_item.dup = lvim.builtin.cmp.formatting.duplicates[entry.source.name] or lvim.builtin.cmp.formatting.duplicates_default @@ -247,6 +250,7 @@ M.config = function() { name = "emoji" }, { name = "treesitter" }, { name = "crates" }, + { name = "tmux" }, }, mapping = cmp.mapping.preset.insert { ["<C-k>"] = cmp.mapping.select_prev_item(), diff --git a/lua/lvim/core/dap.lua b/lua/lvim/core/dap.lua index d9b59641..8f7eb294 100644 --- a/lua/lvim/core/dap.lua +++ b/lua/lvim/core/dap.lua @@ -28,9 +28,11 @@ end M.setup = function() local dap = require "dap" - vim.fn.sign_define("DapBreakpoint", lvim.builtin.dap.breakpoint) - vim.fn.sign_define("DapBreakpointRejected", lvim.builtin.dap.breakpoint_rejected) - vim.fn.sign_define("DapStopped", lvim.builtin.dap.stopped) + if lvim.use_icons then + vim.fn.sign_define("DapBreakpoint", lvim.builtin.dap.breakpoint) + vim.fn.sign_define("DapBreakpointRejected", lvim.builtin.dap.breakpoint_rejected) + vim.fn.sign_define("DapStopped", lvim.builtin.dap.stopped) + end dap.defaults.fallback.terminal_win_cmd = "50vsplit new" diff --git a/lua/lvim/core/gitsigns.lua b/lua/lvim/core/gitsigns.lua index c000cfda..0365fc69 100644 --- a/lua/lvim/core/gitsigns.lua +++ b/lua/lvim/core/gitsigns.lua @@ -73,6 +73,7 @@ M.config = function() sign_priority = 6, update_debounce = 200, status_formatter = nil, -- Use default + yadm = { enable = false }, }, } end diff --git a/lua/lvim/core/info.lua b/lua/lvim/core/info.lua index 00a7e85a..ac7d690a 100644 --- a/lua/lvim/core/info.lua +++ b/lua/lvim/core/info.lua @@ -69,6 +69,7 @@ end local function tbl_set_highlight(terms, highlight_group) for _, v in pairs(terms) do vim.cmd('let m=matchadd("' .. highlight_group .. '", "' .. v .. "[ ,│']\")") + vim.cmd('let m=matchadd("' .. highlight_group .. '", ", ' .. v .. '")') end end diff --git a/lua/lvim/core/lualine/styles.lua b/lua/lvim/core/lualine/styles.lua index 45c6c639..8991d9d9 100644 --- a/lua/lvim/core/lualine/styles.lua +++ b/lua/lvim/core/lualine/styles.lua @@ -11,7 +11,7 @@ styles.none = { style = "none", options = { theme = "auto", - icons_enabled = true, + icons_enabled = lvim.use_icons, component_separators = { left = "", right = "" }, section_separators = { left = "", right = "" }, disabled_filetypes = {}, @@ -40,7 +40,7 @@ styles.default = { style = "default", options = { theme = "auto", - icons_enabled = true, + icons_enabled = lvim.use_icons, component_separators = { left = "", right = "" }, section_separators = { left = "", right = "" }, disabled_filetypes = {}, @@ -69,7 +69,7 @@ styles.lvim = { style = "lvim", options = { theme = "auto", - icons_enabled = true, + icons_enabled = lvim.use_icons, component_separators = { left = "", right = "" }, section_separators = { left = "", right = "" }, disabled_filetypes = { "alpha", "NvimTree", "Outline" }, diff --git a/lua/lvim/core/notify.lua b/lua/lvim/core/notify.lua index cb62778f..2db4c4d5 100644 --- a/lua/lvim/core/notify.lua +++ b/lua/lvim/core/notify.lua @@ -39,6 +39,15 @@ local defaults = { } function M.config() + if not lvim.use_icons then + defaults.opts.icons = { + ERROR = "[ERROR]", + WARN = "[WARNING]", + INFO = "[INFo]", + DEBUG = "[DEBUG]", + TRACE = "[TRACE]", + } + end lvim.builtin.notify = vim.tbl_deep_extend("force", defaults, lvim.builtin.notify or {}) end diff --git a/lua/lvim/core/nvimtree.lua b/lua/lvim/core/nvimtree.lua index 385708ed..e4d28220 100644 --- a/lua/lvim/core/nvimtree.lua +++ b/lua/lvim/core/nvimtree.lua @@ -2,6 +2,7 @@ local M = {} local Log = require "lvim.core.log" function M.config() + local vim_show_icons = lvim.use_icons and 1 or 0 lvim.builtin.nvimtree = { active = true, on_config_done = nil, @@ -9,6 +10,8 @@ function M.config() disable_netrw = true, hijack_netrw = true, open_on_setup = false, + open_on_setup_file = false, + sort_by = "name", ignore_buffer_on_setup = false, ignore_ft_on_setup = { "startify", @@ -21,16 +24,12 @@ function M.config() enable = true, auto_open = true, }, - update_to_buf_dir = { - enable = true, - auto_open = true, - }, - auto_close = false, open_on_tab = false, hijack_cursor = false, update_cwd = false, diagnostics = { - enable = true, + enable = lvim.use_icons, + show_on_dirs = false, icons = { hint = "", info = "", @@ -57,7 +56,7 @@ function M.config() height = 30, hide_root_folder = false, side = "left", - auto_resize = false, + preserve_window_proportions = false, mappings = { custom_only = false, list = {}, @@ -66,34 +65,66 @@ function M.config() relativenumber = false, signcolumn = "yes", }, + renderer = { + indent_markers = { + enable = false, + icons = { + corner = "└ ", + edge = "│ ", + none = " ", + }, + }, + icons = { + webdev_colors = lvim.use_icons, + }, + }, filters = { dotfiles = false, custom = { "node_modules", "\\.cache" }, + exclude = {}, }, trash = { cmd = "trash", require_confirm = true, }, + log = { + enable = false, + truncate = false, + types = { + all = false, + config = false, + copy_paste = false, + diagnostics = false, + git = false, + profile = false, + }, + }, actions = { + use_system_clipboard = true, change_dir = { + enable = true, global = false, + restrict_above_cwd = false, }, open_file = { - resize_window = true, quit_on_open = false, - }, - window_picker = { - enable = false, - chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", - exclude = {}, + resize_window = false, + window_picker = { + enable = true, + chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", + exclude = { + filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, + buftype = { "nofile", "terminal", "help" }, + }, + }, }, }, }, show_icons = { - git = 1, - folders = 1, - files = 1, - folder_arrows = 1, + git = vim_show_icons, + folders = vim_show_icons, + files = vim_show_icons, + folder_arrows = vim_show_icons, }, git_hl = 1, root_folder_modifier = ":t", diff --git a/lua/lvim/core/telescope.lua b/lua/lvim/core/telescope.lua index a4df4b3f..5b55bdc3 100644 --- a/lua/lvim/core/telescope.lua +++ b/lua/lvim/core/telescope.lua @@ -91,24 +91,6 @@ function M.config() }) end -function M.code_actions() - local opts = { - winblend = 15, - layout_config = { - prompt_position = "top", - width = 80, - height = 12, - }, - borderchars = lvim.builtin.telescope.defaults.borderchars, - border = {}, - previewer = false, - shorten_path = false, - } - local builtin = require "telescope.builtin" - local themes = require "telescope.themes" - builtin.lsp_code_actions(themes.get_dropdown(opts)) -end - function M.setup() local previewers = require "telescope.previewers" local sorters = require "telescope.sorters" diff --git a/lua/lvim/core/terminal.lua b/lua/lvim/core/terminal.lua index 69492a57..6c190dd5 100644 --- a/lua/lvim/core/terminal.lua +++ b/lua/lvim/core/terminal.lua @@ -108,6 +108,7 @@ M.toggle_log_view = function(logfile) if vim.fn.executable(log_viewer) ~= 1 then log_viewer = "less +F" end + Log:debug("attempting to open: " .. logfile) log_viewer = log_viewer .. " " .. logfile local term_opts = vim.tbl_deep_extend("force", lvim.builtin.terminal, { cmd = log_viewer, diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index 52b7a9ab..3c3cc66b 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -15,7 +15,7 @@ M.config = function() operators = false, -- adds help for operators like d, y, ... motions = false, -- adds help for motions text_objects = false, -- help for text objects triggered after entering an operator - windows = true, -- default bindings on <c-w> + windows = false, -- default bindings on <c-w> nav = true, -- misc bindings to work with windows z = true, -- bindings for folds, spelling and others prefixed with z g = true, -- bindings for prefixed with g @@ -27,19 +27,35 @@ M.config = function() separator = "➜", -- symbol used between a key and it's label group = "+", -- symbol prepended to a group }, + popup_mappings = { + scroll_down = "<c-d>", -- binding to scroll down inside the popup + scroll_up = "<c-u>", -- binding to scroll up inside the popup + }, window = { border = "single", -- none, single, double, shadow position = "bottom", -- bottom, top margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left] padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left] + winblend = 0, }, layout = { height = { min = 4, max = 25 }, -- min and max height of the columns width = { min = 20, max = 50 }, -- min and max width of the columns spacing = 3, -- spacing between columns + align = "left", -- align columns left, center or right }, hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate + ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label show_help = true, -- show help message on the command line when the popup is visible + triggers = "auto", -- automatically setup triggers + -- triggers = {"<leader>"} -- or specify a list manually + triggers_blacklist = { + -- list of mode / prefixes that should never be hooked by WhichKey + -- this is mostly relevant for key maps that start with a native binding + -- most people should not need to change this + i = { "j", "k" }, + v = { "j", "k" }, + }, }, opts = { @@ -137,32 +153,31 @@ M.config = function() "Git Diff", }, }, - l = { name = "LSP", - a = { "<cmd>lua require('lvim.core.telescope').code_actions()<cr>", "Code Action" }, + a = { "<cmd>lua vim.lsp.buf.code_action()<cr>", "Code Action" }, d = { "<cmd>Telescope diagnostics bufnr=0 theme=get_ivy<cr>", "Buffer Diagnostics" }, w = { "<cmd>Telescope diagnostics<cr>", "Diagnostics" }, - f = { "<cmd>lua vim.lsp.buf.formatting()<cr>", "Format" }, + f = { require("lvim.lsp.utils").format, "Format" }, i = { "<cmd>LspInfo<cr>", "Info" }, I = { "<cmd>LspInstallInfo<cr>", "Installer Info" }, j = { - "<cmd>lua vim.diagnostic.goto_next()<cr>", + vim.diagnostic.goto_next, "Next Diagnostic", }, k = { - "<cmd>lua vim.diagnostic.goto_prev()<cr>", + vim.diagnostic.goto_prev, "Prev Diagnostic", }, - l = { "<cmd>lua vim.lsp.codelens.run()<cr>", "CodeLens Action" }, + l = { vim.lsp.codelens.run, "CodeLens Action" }, p = { name = "Peek", d = { "<cmd>lua require('lvim.lsp.peek').Peek('definition')<cr>", "Definition" }, t = { "<cmd>lua require('lvim.lsp.peek').Peek('typeDefinition')<cr>", "Type Definition" }, i = { "<cmd>lua require('lvim.lsp.peek').Peek('implementation')<cr>", "Implementation" }, }, - q = { "<cmd>lua vim.diagnostic.setloclist()<cr>", "Quickfix" }, - r = { "<cmd>lua vim.lsp.buf.rename()<cr>", "Rename" }, + q = { vim.diagnostic.setloclist, "Quickfix" }, + r = { vim.lsp.buf.rename, "Rename" }, s = { "<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols" }, S = { "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>", @@ -214,10 +229,10 @@ M.config = function() }, N = { "<cmd>edit $NVIM_LOG_FILE<cr>", "Open the Neovim logfile" }, p = { - "<cmd>lua require('lvim.core.terminal').toggle_log_view('packer.nvim')<cr>", + "<cmd>lua require('lvim.core.terminal').toggle_log_view(get_cache_dir() .. '/packer.nvim.log')<cr>", "view packer log", }, - P = { "<cmd>exe 'edit '.stdpath('cache').'/packer.nvim.log'<cr>", "Open the Packer logfile" }, + P = { "<cmd>edit $LUNARVIM_CACHE_DIR/packer.nvim.log<cr>", "Open the Packer logfile" }, }, r = { "<cmd>LvimReload<cr>", "Reload LunarVim's configuration" }, u = { "<cmd>LvimUpdate<cr>", "Update LunarVim" }, |