From 758ea6d07b2060a2802efc25da4b6937150edf61 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Mon, 30 Aug 2021 17:20:02 +0430 Subject: use `gd` to see git diff with previous head (#1426) --- lua/core/which-key.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lua/core') diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 71c0b695..8f2f2a5a 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -130,6 +130,10 @@ M.config = function() "Telescope git_bcommits", "Checkout commit(for current file)", }, + d = { + "Gitsigns diffthis HEAD", + "Git Diff", + }, }, l = { -- cgit v1.2.3 From d5d47d4d7a0b7c396f1bddffe8c5eddc355ce60a Mon Sep 17 00:00:00 2001 From: #!/bin/genesis Date: Fri, 3 Sep 2021 19:44:03 +0300 Subject: [Feature]: Add new which-key command for switching to the last buffer (#1440) * Add new which-key command for switching to last buffer * chore(whichkey) Rework buffer descriptions Co-authored-by: Luc Sinet --- lua/core/which-key.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'lua/core') diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 8f2f2a5a..5ceffb57 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -72,25 +72,26 @@ M.config = function() ["h"] = { "nohlsearch", "No Highlight" }, b = { name = "Buffers", - j = { "BufferPick", "jump to buffer" }, - f = { "Telescope buffers", "Find buffer" }, - w = { "BufferWipeout", "wipeout buffer" }, + j = { "BufferPick", "Jump" }, + f = { "Telescope buffers", "Find" }, + b = { "b#", "Previous" }, + w = { "BufferWipeout", "Wipeout" }, e = { "BufferCloseAllButCurrent", - "close all but current buffer", + "Close all but current", }, - h = { "BufferCloseBuffersLeft", "close all buffers to the left" }, - l = { + l = { "BufferCloseBuffersLeft", "Close all - left" }, + r = { "BufferCloseBuffersRight", - "close all BufferLines to the right", + "Close all - right", }, D = { "BufferOrderByDirectory", - "sort BufferLines automatically by directory", + "Sort by directory", }, L = { "BufferOrderByLanguage", - "sort BufferLines automatically by language", + "Sort by language", }, }, p = { -- cgit v1.2.3 From 8a168ed8773d8e46b9912a57fdd7ef10303872f1 Mon Sep 17 00:00:00 2001 From: Luc Sinet Date: Fri, 3 Sep 2021 22:10:48 +0200 Subject: Revert back buffer bindings (#1458) --- lua/core/which-key.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lua/core') diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 5ceffb57..458e1634 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -80,10 +80,10 @@ M.config = function() "BufferCloseAllButCurrent", "Close all but current", }, - l = { "BufferCloseBuffersLeft", "Close all - left" }, - r = { + h = { "BufferCloseBuffersLeft", "Close all to the left" }, + l = { "BufferCloseBuffersRight", - "Close all - right", + "Close all to the right", }, D = { "BufferOrderByDirectory", -- cgit v1.2.3 From e40182919396dc100630975d68ed879473ec7da4 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sun, 5 Sep 2021 18:33:58 +0430 Subject: [BUGFIX] don't show table address in lualine (#1477) --- lua/core/lualine/components.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lua/core') diff --git a/lua/core/lualine/components.lua b/lua/core/lualine/components.lua index 894d9e9b..3d3ac9af 100644 --- a/lua/core/lualine/components.lua +++ b/lua/core/lualine/components.lua @@ -81,9 +81,12 @@ return { }, lsp = { function(msg) - msg = msg or "LSP Inactive" + msg = msg or "LS Inactive" local buf_clients = vim.lsp.buf_get_clients() if next(buf_clients) == nil then + if #msg == 0 then + return "LS Inactive" + end return msg end local buf_ft = vim.bo.filetype -- cgit v1.2.3 From 151684bba11b702907e58d2acdd41ebc69c27809 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Mon, 6 Sep 2021 22:53:41 +0430 Subject: there was a weird situation that caused lualine msg to turn boolean instead of table (#1492) --- lua/core/lualine/components.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lua/core') diff --git a/lua/core/lualine/components.lua b/lua/core/lualine/components.lua index 3d3ac9af..5d240f46 100644 --- a/lua/core/lualine/components.lua +++ b/lua/core/lualine/components.lua @@ -84,7 +84,8 @@ return { msg = msg or "LS Inactive" local buf_clients = vim.lsp.buf_get_clients() if next(buf_clients) == nil then - if #msg == 0 then + -- TODO: clean up this if statement + if type(msg) == "boolean" or #msg == 0 then return "LS Inactive" end return msg -- cgit v1.2.3 From 9ece2e5369de46962422837be3dce3b8e889805d Mon Sep 17 00:00:00 2001 From: Christian Chiarulli Date: Tue, 7 Sep 2021 19:23:14 -0400 Subject: feat: compe -> cmp (#1496) --- lua/core/autopairs.lua | 52 ++++++++++-------- lua/core/builtins/init.lua | 2 +- lua/core/cmp.lua | 123 +++++++++++++++++++++++++++++++++++++++++ lua/core/compe.lua | 133 --------------------------------------------- 4 files changed, 154 insertions(+), 156 deletions(-) create mode 100644 lua/core/cmp.lua delete mode 100644 lua/core/compe.lua (limited to 'lua/core') diff --git a/lua/core/autopairs.lua b/lua/core/autopairs.lua index 24aa1875..b728cbc1 100644 --- a/lua/core/autopairs.lua +++ b/lua/core/autopairs.lua @@ -20,36 +20,44 @@ function M.config() end M.setup = function() - -- skip it, if you use another global object - _G.MUtils = {} local autopairs = require "nvim-autopairs" local Rule = require "nvim-autopairs.rule" - - vim.g.completion_confirm_key = "" - MUtils.completion_confirm = function() - if vim.fn.pumvisible() ~= 0 then - if vim.fn.complete_info()["selected"] ~= -1 then - return vim.fn["compe#confirm"](autopairs.esc "") - else - return autopairs.esc "" - end - else - return autopairs.autopairs_cr() - end - end - - if package.loaded["compe"] then - require("nvim-autopairs.completion.compe").setup { - map_cr = lvim.builtin.autopairs.map_cr, - map_complete = lvim.builtin.autopairs.map_complete, - } - end + local cond = require "nvim-autopairs.conds" autopairs.setup { check_ts = lvim.builtin.autopairs.check_ts, ts_config = lvim.builtin.autopairs.ts_config, } + -- vim.g.completion_confirm_key = "" + + autopairs.add_rule(Rule("$$", "$$", "tex")) + autopairs.add_rules { + Rule("$", "$", { "tex", "latex" }) -- don't add a pair if the next character is % + :with_pair(cond.not_after_regex_check "%%") -- don't add a pair if the previous character is xxx + :with_pair(cond.not_before_regex_check("xxx", 3)) -- don't move right when repeat character + :with_move(cond.none()) -- don't delete if the next character is xx + :with_del(cond.not_after_regex_check "xx") -- disable add newline when press + :with_cr(cond.none()), + } + autopairs.add_rules { + Rule("$$", "$$", "tex"):with_pair(function(opts) + print(vim.inspect(opts)) + if opts.line == "aa $$" then + -- don't add pair on that line + return false + end + end), + } + + if package.loaded["cmp"] then + require("nvim-autopairs.completion.cmp").setup { + map_cr = true, -- map on insert mode + map_complete = true, -- it will auto insert `(` after select function or method item + auto_select = true, -- automatically select the first item + } + end + require("nvim-treesitter.configs").setup { autopairs = { enable = true } } local ts_conds = require "nvim-autopairs.ts-conds" diff --git a/lua/core/builtins/init.lua b/lua/core/builtins/init.lua index 32f96af5..dc9b5ff5 100644 --- a/lua/core/builtins/init.lua +++ b/lua/core/builtins/init.lua @@ -4,7 +4,7 @@ local builtins = { "keymappings", "core.which-key", "core.gitsigns", - "core.compe", + "core.cmp", "core.dashboard", "core.dap", "core.terminal", diff --git a/lua/core/cmp.lua b/lua/core/cmp.lua new file mode 100644 index 00000000..7f912544 --- /dev/null +++ b/lua/core/cmp.lua @@ -0,0 +1,123 @@ +local M = {} + +local check_backspace = function() + local col = vim.fn.col "." - 1 + return col == 0 or vim.fn.getline("."):sub(col, col):match "%s" +end + +local function T(str) + return vim.api.nvim_replace_termcodes(str, true, true, true) +end + +local is_emmet_active = function() + local clients = vim.lsp.buf_get_clients() + + for _, client in pairs(clients) do + if client.name == "emmet_ls" then + return true + end + end + return false +end + +M.config = function() + local status_cmp_ok, cmp = pcall(require, "cmp") + if not status_cmp_ok then + return + end + local status_luasnip_ok, luasnip = pcall(require, "luasnip") + if not status_luasnip_ok then + return + end + lvim.builtin.cmp = { + formatting = { + format = function(entry, vim_item) + local icons = require("lsp.kind").icons + vim_item.kind = icons[vim_item.kind] + vim_item.menu = ({ + nvim_lsp = "(LSP)", + emoji = "(Emoji)", + path = "(Path)", + calc = "(Calc)", + cmp_tabnine = "(Tabnine)", + vsnip = "(Snippet)", + luasnip = "(Snippet)", + buffer = "(Buffer)", + })[entry.source.name] + vim_item.dup = ({ + buffer = 1, + path = 1, + nvim_lsp = 0, + })[entry.source.name] or 0 + return vim_item + end, + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + documentation = { + border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + }, + sources = { + { name = "nvim_lsp" }, + { name = "path" }, + { name = "luasnip" }, + { name = "cmp_tabnine" }, + { name = "nvim_lua" }, + { name = "buffer" }, + { name = "calc" }, + { name = "emoji" }, + { name = "treesitter" }, + { name = "crates" }, + }, + mapping = { + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + -- TODO: potentially fix emmet nonsense + [""] = cmp.mapping(function() + if vim.fn.pumvisible() == 1 then + vim.fn.feedkeys(T "", "n") + elseif luasnip.expand_or_jumpable() then + vim.fn.feedkeys(T "luasnip-expand-or-jump", "") + elseif check_backspace() then + vim.fn.feedkeys(T "", "n") + elseif is_emmet_active() then + return vim.fn["cmp#complete"]() + else + vim.fn.feedkeys(T "", "n") + end + end, { + "i", + "s", + }), + [""] = cmp.mapping(function(fallback) + if vim.fn.pumvisible() == 1 then + vim.fn.feedkeys(T "", "n") + elseif luasnip.jumpable(-1) then + vim.fn.feedkeys(T "luasnip-jump-prev", "") + else + fallback() + end + end, { + "i", + "s", + }), + + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + }, + } + + M.setup = function() + require("luasnip/loaders/from_vscode").lazy_load() + require("cmp").setup(lvim.builtin.cmp) + end +end + +return M diff --git a/lua/core/compe.lua b/lua/core/compe.lua deleted file mode 100644 index 9eb3dcfa..00000000 --- a/lua/core/compe.lua +++ /dev/null @@ -1,133 +0,0 @@ -local M = {} - -M.config = function() - lvim.builtin.compe = { - active = true, - on_config_done = nil, - autocomplete = true, - debug = false, - min_length = 1, - preselect = "enable", - throttle_time = 80, - source_timeout = 200, - incomplete_delay = 400, - max_abbr_width = 100, - max_kind_width = 100, - max_menu_width = 100, - documentation = { - border = "single", - winhighlight = "NormalFloat:CompeDocumentation,FloatBorder:CompeDocumentationBorder", - max_width = 120, - min_width = 60, - max_height = math.floor(vim.o.lines * 0.3), - min_height = 1, - }, - -- documentation = true, - - source = { - path = { kind = "  (Path)" }, - buffer = { kind = "  (Buffer)" }, - calc = { kind = "  (Calc)" }, - vsnip = { kind = "  (Snippet)" }, - nvim_lsp = { kind = "  (LSP)" }, - nvim_lua = false, - spell = { kind = "  (Spell)" }, - tags = false, - vim_dadbod_completion = false, - snippets_nvim = false, - ultisnips = false, - treesitter = false, - emoji = { kind = " ﲃ (Emoji)", filetypes = { "markdown", "text" } }, - -- for emoji press : (idk if that in compe tho) - }, - - keymap = { - values = { - insert_mode = { - -- [""] = { 'pumvisible() ? "" : ""', { silent = true, noremap = true, expr = true } }, - -- [""] = { 'pumvisible() ? "" : ""', { silent = true, noremap = true, expr = true } }, - [""] = { "compe#complete()", { silent = true, noremap = true, expr = true } }, - [""] = { "compe#close('')", { silent = true, noremap = true, expr = true } }, - [""] = { "compe#scroll({ 'delta': +4 })", { silent = true, noremap = true, expr = true } }, - [""] = { "compe#scroll({ 'delta': -4 })", { silent = true, noremap = true, expr = true } }, - }, - }, - opts = { - insert_mode = { noremap = true, silent = true, expr = true }, - }, - }, - } -end - -M.setup = function() - vim.g.vsnip_snippet_dir = lvim.vsnip_dir - - local compe = require "compe" - - compe.setup(lvim.builtin.compe) - - local t = function(str) - return vim.api.nvim_replace_termcodes(str, true, true, true) - end - - local check_back_space = function() - local col = vim.fn.col "." - 1 - if col == 0 or vim.fn.getline("."):sub(col, col):match "%s" then - return true - else - return false - end - end - - local is_emmet_active = function() - local clients = vim.lsp.buf_get_clients() - - for _, client in pairs(clients) do - if client.name == "emmet_ls" then - return true - end - end - return false - end - - -- Use (s-)tab to: - --- move to prev/next item in completion menuone - --- jump to prev/next snippet's placeholder - _G.tab_complete = function() - if vim.fn.pumvisible() == 1 then - return t "" - elseif vim.fn.call("vsnip#jumpable", { 1 }) == 1 then - return t "(vsnip-jump-next)" - elseif check_back_space() then - return t "" - elseif is_emmet_active() then - return vim.fn["compe#complete"]() - else - return t "" - end - end - - _G.s_tab_complete = function() - if vim.fn.pumvisible() == 1 then - return t "" - elseif vim.fn.call("vsnip#jumpable", { -1 }) == 1 then - return t "(vsnip-jump-prev)" - else - return t "" - end - end - - local keymap = require "keymappings" - keymap.load(lvim.builtin.compe.keymap.values, lvim.builtin.compe.keymap.opts) - - vim.api.nvim_set_keymap("i", "", "v:lua.tab_complete()", { expr = true }) - vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", { expr = true }) - vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", { expr = true }) - vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", { expr = true }) - - if lvim.builtin.compe.on_config_done then - lvim.builtin.compe.on_config_done(compe) - end -end - -return M -- cgit v1.2.3 From 08345170081b5882535eaf32406a9c0e1b0a6f56 Mon Sep 17 00:00:00 2001 From: luetage Date: Thu, 9 Sep 2021 02:43:30 +0200 Subject: Show treesitter icon only with supported filetype (#1512) --- lua/core/lualine/components.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lua/core') diff --git a/lua/core/lualine/components.lua b/lua/core/lualine/components.lua index 5d240f46..c6800f49 100644 --- a/lua/core/lualine/components.lua +++ b/lua/core/lualine/components.lua @@ -71,7 +71,8 @@ return { }, treesitter = { function() - if next(vim.treesitter.highlighter.active) then + local b = vim.api.nvim_get_current_buf() + if next(vim.treesitter.highlighter.active[b]) then return "  " end return "" -- cgit v1.2.3 From ac32f2e64d61291ba4969599827eef515712d5d8 Mon Sep 17 00:00:00 2001 From: Christian Chiarulli Date: Thu, 9 Sep 2021 09:25:12 -0400 Subject: fix: move setup function outside of config function --- lua/core/cmp.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lua/core') diff --git a/lua/core/cmp.lua b/lua/core/cmp.lua index 7f912544..acfb05ae 100644 --- a/lua/core/cmp.lua +++ b/lua/core/cmp.lua @@ -113,11 +113,11 @@ M.config = function() }, }, } +end - M.setup = function() - require("luasnip/loaders/from_vscode").lazy_load() - require("cmp").setup(lvim.builtin.cmp) - end +M.setup = function() + require("luasnip/loaders/from_vscode").lazy_load() + require("cmp").setup(lvim.builtin.cmp) end return M -- cgit v1.2.3 From 8eed75d67f9cbcefb91c4cb5aac0ffd013be25cc Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Mon, 13 Sep 2021 11:28:15 +0200 Subject: refactor: use more flexible paths (#1381) --- lua/core/dashboard.lua | 13 ++----------- lua/core/project.lua | 2 +- lua/core/telescope.lua | 6 ++++-- lua/core/terminal.lua | 2 +- lua/core/which-key.lua | 2 +- 5 files changed, 9 insertions(+), 16 deletions(-) (limited to 'lua/core') diff --git a/lua/core/dashboard.lua b/lua/core/dashboard.lua index a613921f..aa2a7f35 100644 --- a/lua/core/dashboard.lua +++ b/lua/core/dashboard.lua @@ -1,5 +1,5 @@ local M = {} -local home_dir = vim.loop.os_homedir() +local utils = require "utils" M.config = function(config) lvim.builtin.dashboard = { @@ -7,7 +7,7 @@ M.config = function(config) on_config_done = nil, search_handler = "telescope", disable_at_vim_enter = 0, - session_directory = home_dir .. "/.cache/lvim/sessions", + session_directory = utils.join_paths(get_cache_dir(), "sessions"), custom_header = { "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⣀⣀⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣤⣶⣾⠿⠿⠟⠛⠛⠛⠛⠿⠿⣿⣷⣤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", @@ -69,15 +69,6 @@ M.setup = function() vim.g.dashboard_session_directory = lvim.builtin.dashboard.session_directory - vim.cmd "let packages = len(globpath('~/.local/share/lunarvim/site/pack/packer/start', '*', 0, 1))" - - vim.api.nvim_exec( - [[ - let g:dashboard_custom_footer = ['LunarVim loaded '..packages..' plugins  '] -]], - false - ) - require("core.autocmds").define_augroups { _dashboard = { -- seems to be nobuflisted that makes my stuff disappear will do more testing diff --git a/lua/core/project.lua b/lua/core/project.lua index 7fb04933..e7527440 100644 --- a/lua/core/project.lua +++ b/lua/core/project.lua @@ -35,7 +35,7 @@ function M.config() ---@type string ---@usage path to store the project history for use in telescope - datapath = CACHE_PATH, + datapath = get_cache_dir(), } end diff --git a/lua/core/telescope.lua b/lua/core/telescope.lua index 4ae56df0..34c1fb92 100644 --- a/lua/core/telescope.lua +++ b/lua/core/telescope.lua @@ -1,5 +1,7 @@ local M = {} +local utils = require "utils" + function M.config() -- Define this minimal config so that it's available if telescope is not yet available. lvim.builtin.telescope = { @@ -96,7 +98,7 @@ function M.find_lunarvim_files(opts) }, prompt = ">> ", prompt_title = "~ LunarVim files ~", - cwd = CONFIG_PATH, + cwd = utils.join_paths(get_runtime_dir(), "lvim"), find_command = { "git", "ls-files" }, } opts = vim.tbl_deep_extend("force", theme_opts, opts) @@ -111,7 +113,7 @@ function M.grep_lunarvim_files(opts) layout_strategy = "bottom_pane", prompt = ">> ", prompt_title = "~ search LunarVim ~", - cwd = CONFIG_PATH, + cwd = utils.join_paths(get_runtime_dir(), "lvim"), } opts = vim.tbl_deep_extend("force", theme_opts, opts) require("telescope.builtin").live_grep(opts) diff --git a/lua/core/terminal.lua b/lua/core/terminal.lua index f9be8734..87053412 100644 --- a/lua/core/terminal.lua +++ b/lua/core/terminal.lua @@ -95,7 +95,7 @@ local function get_log_path(name) local logger = require "core.log" local file if name == "nvim" then - file = CACHE_PATH .. "/log" + file = utils.join_paths(get_cache_dir(), "log") else file = logger:new({ plugin = name }):get_path() end diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 458e1634..ef74ee51 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -176,7 +176,7 @@ M.config = function() L = { name = "+LunarVim", c = { - "edit ~/.config/lvim/config.lua", + "edit" .. get_config_dir() .. "/config.lua", "Edit config.lua", }, f = { -- cgit v1.2.3 From f0b30f0a83988e6194970838656f9d4e8250e547 Mon Sep 17 00:00:00 2001 From: Christian Chiarulli Date: Tue, 14 Sep 2021 01:33:40 -0400 Subject: fix: no preselect for up/down, c-j/c-k and tab/s-tab --- lua/core/cmp.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lua/core') diff --git a/lua/core/cmp.lua b/lua/core/cmp.lua index acfb05ae..928b7e3a 100644 --- a/lua/core/cmp.lua +++ b/lua/core/cmp.lua @@ -78,7 +78,7 @@ M.config = function() -- TODO: potentially fix emmet nonsense [""] = cmp.mapping(function() if vim.fn.pumvisible() == 1 then - vim.fn.feedkeys(T "", "n") + vim.fn.feedkeys(T "", "n") elseif luasnip.expand_or_jumpable() then vim.fn.feedkeys(T "luasnip-expand-or-jump", "") elseif check_backspace() then @@ -94,7 +94,7 @@ M.config = function() }), [""] = cmp.mapping(function(fallback) if vim.fn.pumvisible() == 1 then - vim.fn.feedkeys(T "", "n") + vim.fn.feedkeys(T "", "n") elseif luasnip.jumpable(-1) then vim.fn.feedkeys(T "luasnip-jump-prev", "") else -- cgit v1.2.3 From df0da6fc75c60c8bd2791b7cdb9d05d12a25bb50 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 15 Sep 2021 23:41:21 +0430 Subject: [bugfix] Update lualine according to the breaking changes (#1558) --- lua/core/lualine/components.lua | 44 ++++++++++++++++++++--------------------- lua/core/lualine/styles.lua | 12 +++++------ 2 files changed, 28 insertions(+), 28 deletions(-) (limited to 'lua/core') diff --git a/lua/core/lualine/components.lua b/lua/core/lualine/components.lua index c6800f49..21e25585 100644 --- a/lua/core/lualine/components.lua +++ b/lua/core/lualine/components.lua @@ -17,31 +17,32 @@ return { function() return " " end, - left_padding = 0, - right_padding = 0, + padding = { left = 0, right = 0 }, color = {}, - condition = nil, + cond = nil, }, branch = { "b:gitsigns_head", icon = " ", color = { gui = "bold" }, - condition = conditions.hide_in_width, + cond = conditions.hide_in_width, }, filename = { "filename", color = {}, - condition = nil, + cond = nil, }, diff = { "diff", source = diff_source, symbols = { added = "  ", modified = "柳", removed = " " }, - color_added = { fg = colors.green }, - color_modified = { fg = colors.yellow }, - color_removed = { fg = colors.red }, + diff_color = { + added = { fg = colors.green }, + modified = { fg = colors.yellow }, + removed = { fg = colors.red }, + }, color = {}, - condition = nil, + cond = nil, }, python_env = { function() @@ -60,14 +61,14 @@ return { return "" end, color = { fg = colors.green }, - condition = conditions.hide_in_width, + cond = conditions.hide_in_width, }, diagnostics = { "diagnostics", sources = { "nvim_lsp" }, symbols = { error = " ", warn = " ", info = " ", hint = " " }, color = {}, - condition = conditions.hide_in_width, + cond = conditions.hide_in_width, }, treesitter = { function() @@ -78,7 +79,7 @@ return { return "" end, color = { fg = colors.green }, - condition = conditions.hide_in_width, + cond = conditions.hide_in_width, }, lsp = { function(msg) @@ -118,10 +119,10 @@ return { end, icon = " ", color = { gui = "bold" }, - condition = conditions.hide_in_width, + cond = conditions.hide_in_width, }, - location = { "location", condition = conditions.hide_in_width, color = {} }, - progress = { "progress", condition = conditions.hide_in_width, color = {} }, + location = { "location", cond = conditions.hide_in_width, color = {} }, + progress = { "progress", cond = conditions.hide_in_width, color = {} }, spaces = { function() local label = "Spaces: " @@ -130,16 +131,16 @@ return { end return label .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " " end, - condition = conditions.hide_in_width, + cond = conditions.hide_in_width, color = {}, }, encoding = { "o:encoding", - upper = true, + fmt = string.upper, color = {}, - condition = conditions.hide_in_width, + cond = conditions.hide_in_width, }, - filetype = { "filetype", condition = conditions.hide_in_width, color = {} }, + filetype = { "filetype", cond = conditions.hide_in_width, color = {} }, scrollbar = { function() local current_line = vim.fn.line "." @@ -149,9 +150,8 @@ return { local index = math.ceil(line_ratio * #chars) return chars[index] end, - left_padding = 0, - right_padding = 0, + padding = { left = 0, right = 0 }, color = { fg = colors.yellow, bg = colors.bg }, - condition = nil, + cond = nil, }, } diff --git a/lua/core/lualine/styles.lua b/lua/core/lualine/styles.lua index 3595e5e3..19097424 100644 --- a/lua/core/lualine/styles.lua +++ b/lua/core/lualine/styles.lua @@ -11,8 +11,8 @@ styles.none = { style = "none", options = { icons_enabled = true, - component_separators = "", - section_separators = "", + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, disabled_filetypes = {}, }, sections = { @@ -39,8 +39,8 @@ styles.default = { style = "default", options = { icons_enabled = true, - component_separators = { "", "" }, - section_separators = { "", "" }, + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, disabled_filetypes = {}, }, sections = { @@ -67,8 +67,8 @@ styles.lvim = { style = "lvim", options = { icons_enabled = true, - component_separators = "", - section_separators = "", + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, disabled_filetypes = { "dashboard", "NvimTree", "Outline" }, }, sections = { -- cgit v1.2.3 From e22f9a21c179901e6dfcbdb68d035e70eae4d9e8 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Thu, 16 Sep 2021 09:58:32 +0200 Subject: fix: more robust reloading (#1556) --- lua/core/which-key.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'lua/core') diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index ef74ee51..3379100d 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -209,6 +209,7 @@ M.config = function() }, P = { "edit ~/.cache/nvim/packer.nvim.log", "Open the Packer logfile" }, }, + r = { "lua require('utils').reload_lv_config()", "Reload configurations" }, }, s = { name = "Search", -- cgit v1.2.3 From d610502f91ba08c9afc6557d892f93bae2bdab13 Mon Sep 17 00:00:00 2001 From: Christian Chiarulli Date: Thu, 16 Sep 2021 10:15:30 -0400 Subject: fix: dashboard footer seems to have disapeared --- lua/core/dashboard.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lua/core') diff --git a/lua/core/dashboard.lua b/lua/core/dashboard.lua index aa2a7f35..0ade4657 100644 --- a/lua/core/dashboard.lua +++ b/lua/core/dashboard.lua @@ -69,6 +69,8 @@ M.setup = function() vim.g.dashboard_session_directory = lvim.builtin.dashboard.session_directory + vim.g.dashboard_custom_footer = lvim.builtin.dashboard.footer + require("core.autocmds").define_augroups { _dashboard = { -- seems to be nobuflisted that makes my stuff disappear will do more testing -- cgit v1.2.3 From 9257e68c05eff293ea15a484d994b83fd7c610d8 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 17 Sep 2021 08:29:35 +0200 Subject: fix: use the correct API for the log-viewer (#1564) --- lua/core/terminal.lua | 9 +++++---- lua/core/which-key.lua | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'lua/core') diff --git a/lua/core/terminal.lua b/lua/core/terminal.lua index 87053412..4525ca63 100644 --- a/lua/core/terminal.lua +++ b/lua/core/terminal.lua @@ -1,5 +1,6 @@ local M = {} local utils = require "utils" +local Log = require "core.log" M.config = function() lvim.builtin["terminal"] = { @@ -81,7 +82,6 @@ end M._exec_toggle = function(exec) local binary = M._split(exec)[1] if vim.fn.executable(binary) ~= 1 then - local Log = require "core.log" Log:error("Unable to run executable " .. binary .. ". Please make sure it is installed properly.") return end @@ -92,12 +92,13 @@ end local function get_log_path(name) --handle custom paths not managed by Plenary.log - local logger = require "core.log" local file if name == "nvim" then - file = utils.join_paths(get_cache_dir(), "log") + file = utils.join_paths(vim.fn.stdpath "cache", "log") + elseif name == "packer.nvim" then + file = utils.join_paths(vim.fn.stdpath "cache", "packer.nvim.log") else - file = logger:new({ plugin = name }):get_path() + file = Log:get_path() end if utils.is_file(file) then return file diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 3379100d..36949467 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -198,16 +198,16 @@ M.config = function() "lua require('core.terminal').toggle_log_view('lunarvim')", "view default log", }, - D = { "edit ~/.cache/nvim/lunarvim.log", "Open the default logfile" }, + D = { "exe 'edit '.stdpath('cache').'/lunarvim.log'", "Open the default logfile" }, n = { "lua require('core.terminal').toggle_log_view('lsp')", "view lsp log" }, - N = { "edit ~/.cache/nvim/log", "Open the Neovim logfile" }, + N = { "edit $NVIM_LOG_FILE", "Open the Neovim logfile" }, l = { "lua require('core.terminal').toggle_log_view('nvim')", "view neovim log" }, - L = { "edit ~/.cache/nvim/lsp.log", "Open the LSP logfile" }, + L = { "exe 'edit '.stdpath('cache').'/lsp.log'", "Open the LSP logfile" }, p = { "lua require('core.terminal').toggle_log_view('packer.nvim')", "view packer log", }, - P = { "edit ~/.cache/nvim/packer.nvim.log", "Open the Packer logfile" }, + P = { "exe 'edit '.stdpath('cache').'/packer.nvim.log'", "Open the Packer logfile" }, }, r = { "lua require('utils').reload_lv_config()", "Reload configurations" }, }, -- cgit v1.2.3 From 254ab2102b5f8f6187321a545998ead4c3abd27a Mon Sep 17 00:00:00 2001 From: chaesngmin Date: Fri, 17 Sep 2021 04:13:52 -0700 Subject: [Feature] Add lunarvim latest release tag to dashboard (#1436) * feat: add lunarvim latest release tag to dashboard * Add a function to center-align text Rename align to align_left Rename shift_left to shift_right * refactor(dashboard): remove unnecessary comment * refactor(dashboard): use `home_dir` variable for `lv_path` * refactor(dashboard): use $LUNARVIM_RUNTIME_DIR for lv_path * feat(bootstrap): add fn that returns lvim version * refactor(dashboard): use version, lunarvim dir with bootstrap fns * build: add global get_version() from bootstrap Co-authored-by: Luc Sinet --- lua/core/dashboard.lua | 13 ++++++++++++- lua/core/info.lua | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'lua/core') diff --git a/lua/core/dashboard.lua b/lua/core/dashboard.lua index 0ade4657..44c4e38c 100644 --- a/lua/core/dashboard.lua +++ b/lua/core/dashboard.lua @@ -69,7 +69,18 @@ M.setup = function() vim.g.dashboard_session_directory = lvim.builtin.dashboard.session_directory - vim.g.dashboard_custom_footer = lvim.builtin.dashboard.footer + local lvim_site = "lunarvim.org" + local lvim_version = get_version "short" + local num_plugins_loaded = #vim.fn.globpath(get_runtime_dir() .. "/site/pack/packer/start", "*", 0, 1) + + local text = require "interface.text" + vim.g.dashboard_custom_footer = text.align_center({ width = 0 }, { + "LunarVim loaded " .. num_plugins_loaded .. " plugins ", + "", + "v" .. lvim_version, + "", + lvim_site, + }, 0.49) -- Use 0.49 as  counts for 2 characters require("core.autocmds").define_augroups { _dashboard = { diff --git a/lua/core/info.lua b/lua/core/info.lua index 67e45d1c..b8d51a8c 100644 --- a/lua/core/info.lua +++ b/lua/core/info.lua @@ -97,7 +97,7 @@ function M.toggle_popup(ft) local caps_text = "* Capabilities list: " local caps_text_len = caps_text:len() local enabled_caps = text.format_table(client_enabled_caps, 3, " | ") - enabled_caps = text.shift_left(enabled_caps, caps_text_len) + enabled_caps = text.shift_right(enabled_caps, caps_text_len) enabled_caps[1] = fmt("%s%s", caps_text, enabled_caps[1]:sub(caps_text_len + 1)) vim.list_extend(lsp_info, enabled_caps) end @@ -155,7 +155,7 @@ function M.toggle_popup(ft) vim.list_extend(content, section) end - return text.align(popup, content, 0.5) + return text.align_left(popup, content, 0.5) end local function set_syntax_hl() -- cgit v1.2.3 From 390f277b702fe7877f0d5fabbece230528b58cb1 Mon Sep 17 00:00:00 2001 From: chaesngmin Date: Fri, 17 Sep 2021 05:14:31 -0700 Subject: fix(dashboard): hide version when no tag found (#1572) --- lua/core/dashboard.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'lua/core') diff --git a/lua/core/dashboard.lua b/lua/core/dashboard.lua index 44c4e38c..505350cb 100644 --- a/lua/core/dashboard.lua +++ b/lua/core/dashboard.lua @@ -73,14 +73,19 @@ M.setup = function() local lvim_version = get_version "short" local num_plugins_loaded = #vim.fn.globpath(get_runtime_dir() .. "/site/pack/packer/start", "*", 0, 1) - local text = require "interface.text" - vim.g.dashboard_custom_footer = text.align_center({ width = 0 }, { + local footer = { "LunarVim loaded " .. num_plugins_loaded .. " plugins ", "", - "v" .. lvim_version, - "", lvim_site, - }, 0.49) -- Use 0.49 as  counts for 2 characters + } + + if lvim_version then + table.insert(footer, 2, "") + table.insert(footer, 3, "v" .. lvim_version) + end + + local text = require "interface.text" + vim.g.dashboard_custom_footer = text.align_center({ width = 0 }, footer, 0.49) -- Use 0.49 as  counts for 2 characters require("core.autocmds").define_augroups { _dashboard = { -- cgit v1.2.3 From 87d36102919df97ec15af4c916e37888cee279cd Mon Sep 17 00:00:00 2001 From: xeluxee <88047141+xeluxee@users.noreply.github.com> Date: Fri, 17 Sep 2021 18:39:26 +0200 Subject: [Bugfix]: latex completion: insert `{` instead of `(` when completing (#1566) --- lua/core/autopairs.lua | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'lua/core') diff --git a/lua/core/autopairs.lua b/lua/core/autopairs.lua index b728cbc1..a67f3b07 100644 --- a/lua/core/autopairs.lua +++ b/lua/core/autopairs.lua @@ -7,8 +7,16 @@ function M.config() ---@usage map on insert mode map_cr = true, ---@usage auto insert after select function or method item - -- NOTE: This should be wrapped into a function so that it is re-evaluated when opening new files - map_complete = vim.bo.filetype ~= "tex", + map_complete = true, + ---@usage automatically select the first item + auto_select = true, + ---@usage use insert confirm behavior instead of replace + insert = false, + ---@usage -- modifies the function or method delimiter by filetypes + map_char = { + all = "(", + tex = "{", + }, ---@usage check treesitter check_ts = true, ts_config = { @@ -52,9 +60,11 @@ M.setup = function() if package.loaded["cmp"] then require("nvim-autopairs.completion.cmp").setup { - map_cr = true, -- map on insert mode - map_complete = true, -- it will auto insert `(` after select function or method item - auto_select = true, -- automatically select the first item + map_cr = lvim.builtin.autopairs.map_cr, + map_complete = lvim.builtin.autopairs.map_complete, + auto_select = lvim.builtin.autopairs.auto_select, + insert = lvim.builtin.autopairs.insert, + map_char = lvim.builtin.autopairs.map_char, } end -- cgit v1.2.3 From fbfd8c1fc3d0df1e2169df64c2264de7e23a9105 Mon Sep 17 00:00:00 2001 From: Chase Colman <5411+chase@users.noreply.github.com> Date: Tue, 21 Sep 2021 14:54:47 +0800 Subject: feature: allow cmp confirm options to be configurable (#1523) --- lua/core/cmp.lua | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lua/core') diff --git a/lua/core/cmp.lua b/lua/core/cmp.lua index 928b7e3a..2bc724fb 100644 --- a/lua/core/cmp.lua +++ b/lua/core/cmp.lua @@ -30,6 +30,10 @@ M.config = function() return end lvim.builtin.cmp = { + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, formatting = { format = function(entry, vim_item) local icons = require("lsp.kind").icons @@ -107,10 +111,15 @@ M.config = function() [""] = cmp.mapping.complete(), [""] = cmp.mapping.close(), - [""] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, + [""] = cmp.mapping(function(fallback) + if not require("cmp").confirm(lvim.builtin.cmp.confirm_opts) then + if luasnip.jumpable() then + vim.fn.feedkeys(T "luasnip-jump-next", "") + else + fallback() + end + end + end), }, } end -- cgit v1.2.3 From 9b76a13512b407f23eb9fc16d0210daccccf4802 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sat, 25 Sep 2021 10:35:08 +0330 Subject: watch_index is deprecated, use watch_gitdir instead (#1614) --- lua/core/gitsigns.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua/core') diff --git a/lua/core/gitsigns.lua b/lua/core/gitsigns.lua index bb9d088b..cc6387dc 100644 --- a/lua/core/gitsigns.lua +++ b/lua/core/gitsigns.lua @@ -44,7 +44,7 @@ M.config = function() noremap = true, buffer = true, }, - watch_index = { interval = 1000 }, + watch_gitdir = { interval = 1000 }, sign_priority = 6, update_debounce = 200, status_formatter = nil, -- Use default -- cgit v1.2.3 From 810fc26fdf05504f813f049eb8d5277260e08d21 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sat, 25 Sep 2021 18:39:12 +0200 Subject: fix: adjust layout after a regression in telescope (#1615) --- lua/core/telescope.lua | 5 ----- 1 file changed, 5 deletions(-) (limited to 'lua/core') diff --git a/lua/core/telescope.lua b/lua/core/telescope.lua index 34c1fb92..e24a976e 100644 --- a/lua/core/telescope.lua +++ b/lua/core/telescope.lua @@ -89,13 +89,8 @@ function M.find_lunarvim_files(opts) opts = opts or {} local themes = require "telescope.themes" local theme_opts = themes.get_ivy { - previewer = false, sorting_strategy = "ascending", layout_strategy = "bottom_pane", - layout_config = { - height = 5, - width = 0.5, - }, prompt = ">> ", prompt_title = "~ LunarVim files ~", cwd = utils.join_paths(get_runtime_dir(), "lvim"), -- cgit v1.2.3 From 64a5964b545ec7f3f78f725ec96cba553a496d9f Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sat, 25 Sep 2021 20:47:50 +0330 Subject: update nvim-tree based on the refactor (#1617) --- lua/core/nvimtree.lua | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'lua/core') diff --git a/lua/core/nvimtree.lua b/lua/core/nvimtree.lua index 6aa5401d..5007cf7c 100644 --- a/lua/core/nvimtree.lua +++ b/lua/core/nvimtree.lua @@ -57,16 +57,12 @@ function M.setup() end local g = vim.g - for opt, val in pairs(lvim.builtin.nvimtree) do - g["nvim_tree_" .. opt] = val - end - -- Implicitly update nvim-tree when project module is active if lvim.builtin.project.active then - vim.g.nvim_tree_update_cwd = 1 - vim.g.nvim_tree_respect_buf_cwd = 1 - vim.g.nvim_tree_disable_netrw = 0 - vim.g.nvim_tree_hijack_netrw = 0 + lvim.builtin.nvimtree.update_cwd = 1 + lvim.builtin.nvimtree.respect_buf_cwd = 1 + lvim.builtin.nvimtree.disable_netrw = 0 + lvim.builtin.nvimtree.hijack_netrw = 0 vim.g.netrw_banner = 0 end @@ -96,6 +92,7 @@ function M.setup() if lvim.builtin.nvimtree.on_config_done then lvim.builtin.nvimtree.on_config_done(nvim_tree_config) end + require("nvim-tree").setup(lvim.builtin.nvimtree) end function M.on_open() -- cgit v1.2.3 From 8009ff4fee6c46f2ea80b084447fe2052740c378 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sun, 26 Sep 2021 09:37:06 +0330 Subject: fix: use the new nvim-tree syntax (#1619) --- lua/core/nvimtree.lua | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'lua/core') diff --git a/lua/core/nvimtree.lua b/lua/core/nvimtree.lua index 5007cf7c..44d3031f 100644 --- a/lua/core/nvimtree.lua +++ b/lua/core/nvimtree.lua @@ -6,6 +6,14 @@ function M.config() active = true, on_config_done = nil, side = "left", + setup = { + auto_open = 0, + auto_close = 1, + tab_open = 0, + update_focused_file = { + enable = 1, + }, + }, width = 30, show_icons = { git = 1, @@ -15,14 +23,10 @@ function M.config() tree_width = 30, }, ignore = { ".git", "node_modules", ".cache" }, - auto_open = 0, - auto_close = 1, quit_on_open = 0, - follow = 1, hide_dotfiles = 1, git_hl = 1, root_folder_modifier = ":t", - tab_open = 0, allow_resize = 1, lsp_diagnostics = 1, auto_ignore_ft = { "startify", "dashboard" }, @@ -57,12 +61,16 @@ function M.setup() end local g = vim.g + for opt, val in pairs(lvim.builtin.nvimtree) do + g["nvim_tree_" .. opt] = val + end + -- Implicitly update nvim-tree when project module is active if lvim.builtin.project.active then - lvim.builtin.nvimtree.update_cwd = 1 lvim.builtin.nvimtree.respect_buf_cwd = 1 - lvim.builtin.nvimtree.disable_netrw = 0 - lvim.builtin.nvimtree.hijack_netrw = 0 + lvim.builtin.nvimtree.setup.update_cwd = 1 + lvim.builtin.nvimtree.setup.disable_netrw = 0 + lvim.builtin.nvimtree.setup.hijack_netrw = 0 vim.g.netrw_banner = 0 end @@ -92,7 +100,7 @@ function M.setup() if lvim.builtin.nvimtree.on_config_done then lvim.builtin.nvimtree.on_config_done(nvim_tree_config) end - require("nvim-tree").setup(lvim.builtin.nvimtree) + require("nvim-tree").setup(lvim.builtin.nvimtree.setup) end function M.on_open() -- cgit v1.2.3 From 1d96533f17103fc05f2b64921137bba11224e6b0 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sun, 26 Sep 2021 13:33:54 +0330 Subject: lsp_diagnostics is part of the nvim-tree setup now (#1623) --- lua/core/nvimtree.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua/core') diff --git a/lua/core/nvimtree.lua b/lua/core/nvimtree.lua index 44d3031f..dfcbb1fa 100644 --- a/lua/core/nvimtree.lua +++ b/lua/core/nvimtree.lua @@ -13,6 +13,7 @@ function M.config() update_focused_file = { enable = 1, }, + lsp_diagnostics = 1, }, width = 30, show_icons = { @@ -28,7 +29,6 @@ function M.config() git_hl = 1, root_folder_modifier = ":t", allow_resize = 1, - lsp_diagnostics = 1, auto_ignore_ft = { "startify", "dashboard" }, icons = { default = "", -- cgit v1.2.3 From 62b805448d1fdb9236ee6b4da41e3d7ef1acc8df Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sun, 26 Sep 2021 20:06:34 +0330 Subject: migrate nvim-tree to setup syntax episode 4 :cry: (#1627) --- lua/core/nvimtree.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lua/core') diff --git a/lua/core/nvimtree.lua b/lua/core/nvimtree.lua index dfcbb1fa..db017fd0 100644 --- a/lua/core/nvimtree.lua +++ b/lua/core/nvimtree.lua @@ -5,7 +5,6 @@ function M.config() lvim.builtin.nvimtree = { active = true, on_config_done = nil, - side = "left", setup = { auto_open = 0, auto_close = 1, @@ -14,8 +13,15 @@ function M.config() enable = 1, }, lsp_diagnostics = 1, + view = { + width = 30, + side = "left", + auto_resize = false, + mappings = { + custom_only = false, + }, + }, }, - width = 30, show_icons = { git = 1, folders = 1, @@ -76,8 +82,8 @@ function M.setup() local tree_cb = nvim_tree_config.nvim_tree_callback - if not g.nvim_tree_bindings then - g.nvim_tree_bindings = { + if not lvim.builtin.nvimtree.setup.view.mappings.list then + lvim.builtin.nvimtree.setup.view.mappings.list = { { key = { "l", "", "o" }, cb = tree_cb "edit" }, { key = "h", cb = tree_cb "close_node" }, { key = "v", cb = tree_cb "vsplit" }, -- cgit v1.2.3 From 238bbf18ac4e35152be06736c75e94a81e3382e8 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sun, 26 Sep 2021 21:11:44 +0330 Subject: fix small bugs in nvim-tree (#1629) --- lua/core/nvimtree.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lua/core') diff --git a/lua/core/nvimtree.lua b/lua/core/nvimtree.lua index db017fd0..8d3b1b6a 100644 --- a/lua/core/nvimtree.lua +++ b/lua/core/nvimtree.lua @@ -110,8 +110,8 @@ function M.setup() end function M.on_open() - if package.loaded["bufferline.state"] and lvim.builtin.nvimtree.side == "left" then - require("bufferline.state").set_offset(lvim.builtin.nvimtree.width + 1, "") + if package.loaded["bufferline.state"] and lvim.builtin.nvimtree.setup.view.side == "left" then + require("bufferline.state").set_offset(lvim.builtin.nvimtree.setup.view.width + 1, "") end end -- cgit v1.2.3 From 35d5615ecc2366ec5de4ce0fecd75fb426216ea0 Mon Sep 17 00:00:00 2001 From: Xavier Young <45989017+younger-1@users.noreply.github.com> Date: Thu, 30 Sep 2021 13:42:10 +0800 Subject: fix: can't open lvim log file cause by `lvim.log.viewer.cmd` (#1638) --- lua/core/terminal.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lua/core') diff --git a/lua/core/terminal.lua b/lua/core/terminal.lua index 4525ca63..418dc2c4 100644 --- a/lua/core/terminal.lua +++ b/lua/core/terminal.lua @@ -112,8 +112,14 @@ M.toggle_log_view = function(name) if not logfile then return end + + local log_viewer = lvim.log.viewer.cmd + if vim.fn.executable(log_viewer) ~= 1 then + log_viewer = "less +F" + end + log_viewer = log_viewer .. " " .. logfile local term_opts = vim.tbl_deep_extend("force", lvim.builtin.terminal, { - cmd = lvim.log.viewer.cmd .. " " .. logfile, + cmd = log_viewer, open_mapping = lvim.log.viewer.layout_config.open_mapping, direction = lvim.log.viewer.layout_config.direction, -- TODO: this might not be working as expected -- cgit v1.2.3 From 8ec92c0420374097f1a617fe91cd6f6a5503c5b0 Mon Sep 17 00:00:00 2001 From: Subho Banerjee Date: Thu, 30 Sep 2021 02:31:59 -0500 Subject: Feature: Define signs for Dap (#1642) --- lua/core/dap.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lua/core') diff --git a/lua/core/dap.lua b/lua/core/dap.lua index 5de3b7c4..d9b59641 100644 --- a/lua/core/dap.lua +++ b/lua/core/dap.lua @@ -10,6 +10,18 @@ M.config = function() linehl = "", numhl = "", }, + breakpoint_rejected = { + text = "", + texthl = "LspDiagnosticsSignHint", + linehl = "", + numhl = "", + }, + stopped = { + text = "", + texthl = "LspDiagnosticsSignInformation", + linehl = "DiagnosticUnderlineInfo", + numhl = "LspDiagnosticsSignInformation", + }, } end @@ -17,6 +29,9 @@ 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) + dap.defaults.fallback.terminal_win_cmd = "50vsplit new" lvim.builtin.which_key.mappings["d"] = { -- cgit v1.2.3 From a273c46eee751de4a61360ae0076ed4dac433e5d Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 1 Oct 2021 13:27:06 +0200 Subject: feat: add LvimUpdate command (#1634) * feat: add prelimenary LvimUpdate command * feat: use native process management * feat: add a telescope change-log utility * fix: update readme to include the new command --- lua/core/commands.lua | 2 ++ lua/core/telescope.lua | 45 +++++++++++++++++++++++++++++++++++++++++++++ lua/core/which-key.lua | 5 +++++ 3 files changed, 52 insertions(+) (limited to 'lua/core') diff --git a/lua/core/commands.lua b/lua/core/commands.lua index 22170c85..f732c9a2 100644 --- a/lua/core/commands.lua +++ b/lua/core/commands.lua @@ -12,6 +12,8 @@ M.defaults = { ]], -- :LvimInfo [[command! LvimInfo lua require('core.info').toggle_popup(vim.bo.filetype)]], + [[ command! LvimCacheReset lua require('bootstrap').reset_cache() ]], + [[ command! LvimUpdate lua require('bootstrap').update() ]], } M.load = function(commands) diff --git a/lua/core/telescope.lua b/lua/core/telescope.lua index e24a976e..eba27eec 100644 --- a/lua/core/telescope.lua +++ b/lua/core/telescope.lua @@ -114,6 +114,51 @@ function M.grep_lunarvim_files(opts) require("telescope.builtin").live_grep(opts) end +function M.view_lunarvim_changelog() + local finders = require "telescope.finders" + local make_entry = require "telescope.make_entry" + local pickers = require "telescope.pickers" + local previewers = require "telescope.previewers" + local actions = require "telescope.actions" + local opts = {} + + local conf = require("telescope.config").values + opts.entry_maker = make_entry.gen_from_git_commits(opts) + + pickers.new(opts, { + prompt_title = "LunarVim changelog", + + finder = finders.new_oneshot_job( + vim.tbl_flatten { + "git", + "log", + "--pretty=oneline", + "--abbrev-commit", + "--", + ".", + }, + opts + ), + previewer = { + previewers.git_commit_diff_to_parent.new(opts), + previewers.git_commit_diff_to_head.new(opts), + previewers.git_commit_diff_as_was.new(opts), + previewers.git_commit_message.new(opts), + }, + + --TODO: consider opening a diff view when pressing enter + attach_mappings = function(_, map) + map("i", "", actions._close) + map("n", "", actions._close) + map("i", "", actions._close) + map("n", "", actions._close) + map("n", "q", actions._close) + return true + end, + sorter = conf.file_sorter(opts), + }):find() +end + function M.setup() local telescope = require "telescope" diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 36949467..2e528048 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -192,6 +192,10 @@ M.config = function() "lua require('core.info').toggle_popup(vim.bo.filetype)", "Toggle LunarVim Info", }, + I = { + "lua require('core.telescope').view_lunarvim_changelog()", + "View LunarVim's changelog", + }, l = { name = "+logs", d = { @@ -210,6 +214,7 @@ M.config = function() P = { "exe 'edit '.stdpath('cache').'/packer.nvim.log'", "Open the Packer logfile" }, }, r = { "lua require('utils').reload_lv_config()", "Reload configurations" }, + u = { "LvimUpdate", "Update LunarVim" }, }, s = { name = "Search", -- cgit v1.2.3 From 3e1cd1ec235404ae96ed2d0756729cf44ae48f3e Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sun, 3 Oct 2021 14:32:09 +0200 Subject: fix: add missing lsp.log entry in log_viewer (#1666) --- lua/core/terminal.lua | 26 ++------------------------ lua/core/which-key.lua | 13 ++++++++----- 2 files changed, 10 insertions(+), 29 deletions(-) (limited to 'lua/core') diff --git a/lua/core/terminal.lua b/lua/core/terminal.lua index 418dc2c4..3a0c6e46 100644 --- a/lua/core/terminal.lua +++ b/lua/core/terminal.lua @@ -1,5 +1,4 @@ local M = {} -local utils = require "utils" local Log = require "core.log" M.config = function() @@ -90,29 +89,9 @@ M._exec_toggle = function(exec) exec_term:toggle() end -local function get_log_path(name) - --handle custom paths not managed by Plenary.log - local file - if name == "nvim" then - file = utils.join_paths(vim.fn.stdpath "cache", "log") - elseif name == "packer.nvim" then - file = utils.join_paths(vim.fn.stdpath "cache", "packer.nvim.log") - else - file = Log:get_path() - end - if utils.is_file(file) then - return file - end -end - ---Toggles a log viewer according to log.viewer.layout_config ----@param name can be the name of any of the managed logs, e,g. "lunarvim" or the default ones {"nvim", "lsp", "packer.nvim"} -M.toggle_log_view = function(name) - local logfile = get_log_path(name) - if not logfile then - return - end - +---@param logfile string the fullpath to the logfile +M.toggle_log_view = function(logfile) local log_viewer = lvim.log.viewer.cmd if vim.fn.executable(log_viewer) ~= 1 then log_viewer = "less +F" @@ -129,7 +108,6 @@ M.toggle_log_view = function(name) local Terminal = require("toggleterm.terminal").Terminal local log_view = Terminal:new(term_opts) - -- require("core.log"):debug("term", vim.inspect(term_opts)) log_view:toggle() end diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 2e528048..27cec37c 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -199,14 +199,17 @@ M.config = function() l = { name = "+logs", d = { - "lua require('core.terminal').toggle_log_view('lunarvim')", + "lua require('core.terminal').toggle_log_view(require('core.log').get_path())", "view default log", }, - D = { "exe 'edit '.stdpath('cache').'/lunarvim.log'", "Open the default logfile" }, - n = { "lua require('core.terminal').toggle_log_view('lsp')", "view lsp log" }, + D = { "lua vim.fn.execute('edit ' .. require('core.log').get_path())", "Open the default logfile" }, + l = { "lua require('core.terminal').toggle_log_view(vim.lsp.get_log_path())", "view lsp log" }, + L = { "lua vim.fn.execute('edit ' .. vim.lsp.get_log_path())", "Open the LSP logfile" }, + n = { + "lua require('core.terminal').toggle_log_view(os.getenv('NVIM_LOG_FILE'))", + "view neovim log", + }, N = { "edit $NVIM_LOG_FILE", "Open the Neovim logfile" }, - l = { "lua require('core.terminal').toggle_log_view('nvim')", "view neovim log" }, - L = { "exe 'edit '.stdpath('cache').'/lsp.log'", "Open the LSP logfile" }, p = { "lua require('core.terminal').toggle_log_view('packer.nvim')", "view packer log", -- cgit v1.2.3 From d01ba08eaec1640ac2d038893525b3ba0af25813 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sun, 3 Oct 2021 16:13:46 +0200 Subject: refactor: auto-generate language configuration (#1584) Refactor the monolithic `lvim.lang` design into a more modular approach. IMPORTANT: run `:LvimUpdate` in order to generate the new ftplugin template files. --- lua/core/builtins/init.lua | 1 - lua/core/cmp.lua | 30 +++++++++++++- lua/core/info.lua | 87 ++++++++++++++++++----------------------- lua/core/log.lua | 1 + lua/core/lspinstall.lua | 19 --------- lua/core/lualine/components.lua | 3 -- lua/core/which-key.lua | 2 +- 7 files changed, 68 insertions(+), 75 deletions(-) delete mode 100644 lua/core/lspinstall.lua (limited to 'lua/core') diff --git a/lua/core/builtins/init.lua b/lua/core/builtins/init.lua index dc9b5ff5..c3b3618f 100644 --- a/lua/core/builtins/init.lua +++ b/lua/core/builtins/init.lua @@ -15,7 +15,6 @@ local builtins = { "core.bufferline", "core.autopairs", "core.comment", - "core.lspinstall", "core.lualine", } diff --git a/lua/core/cmp.lua b/lua/core/cmp.lua index 2bc724fb..965285c7 100644 --- a/lua/core/cmp.lua +++ b/lua/core/cmp.lua @@ -35,9 +35,35 @@ M.config = function() select = true, }, formatting = { + kind_icons = { + Class = " ", + Color = " ", + Constant = "ﲀ ", + Constructor = " ", + Enum = "練", + EnumMember = " ", + Event = " ", + Field = " ", + File = "", + Folder = " ", + Function = " ", + Interface = "ﰮ ", + Keyword = " ", + Method = " ", + Module = " ", + Operator = "", + Property = " ", + Reference = " ", + Snippet = " ", + Struct = " ", + Text = " ", + TypeParameter = " ", + Unit = "塞", + Value = " ", + Variable = " ", + }, format = function(entry, vim_item) - local icons = require("lsp.kind").icons - vim_item.kind = icons[vim_item.kind] + vim_item.kind = lvim.builtin.cmp.formatting.kind_icons[vim_item.kind] vim_item.menu = ({ nvim_lsp = "(LSP)", emoji = "(Emoji)", diff --git a/lua/core/info.lua b/lua/core/info.lua index b8d51a8c..ff024fa5 100644 --- a/lua/core/info.lua +++ b/lua/core/info.lua @@ -10,6 +10,7 @@ local M = { } local fmt = string.format +local text = require "interface.text" local function str_list(list) return fmt("[ %s ]", table.concat(list, ", ")) @@ -65,44 +66,55 @@ local function tbl_set_highlight(terms, highlight_group) end end +local function make_client_info(client) + local client_enabled_caps = require("lsp.utils").get_ls_capabilities(client.id) + local name = client.name + local id = client.id + local document_formatting = client.resolved_capabilities.document_formatting + local client_info = { + fmt("* Name: %s", name), + fmt("* Id: %s", tostring(id)), + fmt("* Supports formatting: %s", tostring(document_formatting)), + } + if not vim.tbl_isempty(client_enabled_caps) then + local caps_text = "* Capabilities list: " + local caps_text_len = caps_text:len() + local enabled_caps = text.format_table(client_enabled_caps, 3, " | ") + enabled_caps = text.shift_right(enabled_caps, caps_text_len) + enabled_caps[1] = fmt("%s%s", caps_text, enabled_caps[1]:sub(caps_text_len + 1)) + vim.list_extend(client_info, enabled_caps) + end + + return client_info +end + function M.toggle_popup(ft) local lsp_utils = require "lsp.utils" - local client = lsp_utils.get_active_client_by_ft(ft) - local is_client_active = false - local client_enabled_caps = {} - local client_name = "" - local client_id = 0 - local document_formatting = false - if client ~= nil then - is_client_active = not client.is_stopped() - client_enabled_caps = require("lsp").get_ls_capabilities(client.id) - client_name = client.name - client_id = client.id - document_formatting = client.resolved_capabilities.document_formatting - end + local clients = lsp_utils.get_active_client_by_ft(ft) + local client_names = {} local header = { fmt("Detected filetype: %s", ft), fmt("Treesitter active: %s", tostring(next(vim.treesitter.highlighter.active) ~= nil)), } - local text = require "interface.text" local lsp_info = { "Language Server Protocol (LSP) info", - fmt("* Associated server: %s", client_name), - fmt("* Active: %s (id: %d)", tostring(is_client_active), client_id), - fmt("* Supports formatting: %s", tostring(document_formatting)), + fmt "* Associated server(s):", } - if not vim.tbl_isempty(client_enabled_caps) then - local caps_text = "* Capabilities list: " - local caps_text_len = caps_text:len() - local enabled_caps = text.format_table(client_enabled_caps, 3, " | ") - enabled_caps = text.shift_right(enabled_caps, caps_text_len) - enabled_caps[1] = fmt("%s%s", caps_text, enabled_caps[1]:sub(caps_text_len + 1)) - vim.list_extend(lsp_info, enabled_caps) + + for _, client in pairs(clients) do + vim.list_extend(lsp_info, make_client_info(client)) + table.insert(client_names, client.name) end - local null_ls = require "lsp.null-ls" - local registered_providers = null_ls.list_supported_provider_names(ft) + + local null_formatters = require "lsp.null-ls.formatters" + local null_linters = require "lsp.null-ls.linters" + local registered_formatters = null_formatters.list_supported_names(ft) + local registered_linters = null_linters.list_supported_names(ft) + local registered_providers = {} + vim.list_extend(registered_providers, registered_formatters) + vim.list_extend(registered_providers, registered_linters) local registered_count = vim.tbl_count(registered_providers) local null_ls_info = { "Formatters and linters", @@ -113,24 +125,6 @@ function M.toggle_popup(ft) ), } - local null_formatters = require "lsp.null-ls.formatters" - local missing_formatters = null_formatters.list_unsupported_names(ft) - local missing_formatters_status = {} - if not vim.tbl_isempty(missing_formatters) then - missing_formatters_status = { - fmt("* Missing formatters: %s", table.concat(missing_formatters, "  , ") .. "  "), - } - end - - local null_linters = require "lsp.null-ls.linters" - local missing_linters = null_linters.list_unsupported_names(ft) - local missing_linters_status = {} - if not vim.tbl_isempty(missing_linters) then - missing_linters_status = { - fmt("* Missing linters: %s", table.concat(missing_linters, "  , ") .. "  "), - } - end - local content_provider = function(popup) local content = {} @@ -143,8 +137,6 @@ function M.toggle_popup(ft) lsp_info, { "" }, null_ls_info, - missing_formatters_status, - missing_linters_status, { "" }, { "" }, get_formatter_suggestion_msg(ft), @@ -167,11 +159,8 @@ function M.toggle_popup(ft) vim.cmd 'let m=matchadd("string", "true")' vim.cmd 'let m=matchadd("error", "false")' tbl_set_highlight(registered_providers, "LvimInfoIdentifier") - tbl_set_highlight(missing_formatters, "LvimInfoIdentifier") - tbl_set_highlight(missing_linters, "LvimInfoIdentifier") -- tbl_set_highlight(require("lsp.null-ls.formatters").list_available(ft), "LvimInfoIdentifier") -- tbl_set_highlight(require("lsp.null-ls.linters").list_available(ft), "LvimInfoIdentifier") - vim.cmd('let m=matchadd("LvimInfoIdentifier", "' .. client_name .. '")') end local Popup = require("interface.popup"):new { diff --git a/lua/core/log.lua b/lua/core/log.lua index 1eb786ba..fca1fcb4 100644 --- a/lua/core/log.lua +++ b/lua/core/log.lua @@ -8,6 +8,7 @@ function Log:add_entry(msg, level) if self.__handle then -- plenary uses lower-case log levels self.__handle[level:lower()](msg) + return end local status_ok, plenary = pcall(require, "plenary") if status_ok then diff --git a/lua/core/lspinstall.lua b/lua/core/lspinstall.lua deleted file mode 100644 index 0bb59e0e..00000000 --- a/lua/core/lspinstall.lua +++ /dev/null @@ -1,19 +0,0 @@ -local M = {} - -M.config = function() - lvim.builtin.lspinstall = { - active = true, - on_config_done = nil, - } -end - -M.setup = function() - local lspinstall = require "lspinstall" - lspinstall.setup() - - if lvim.builtin.lspinstall.on_config_done then - lvim.builtin.lspinstall.on_config_done(lspinstall) - end -end - -return M diff --git a/lua/core/lualine/components.lua b/lua/core/lualine/components.lua index 21e25585..3ee2fdf8 100644 --- a/lua/core/lualine/components.lua +++ b/lua/core/lualine/components.lua @@ -96,14 +96,11 @@ return { local buf_client_names = {} -- add client - local utils = require "lsp.utils" - local active_client = utils.get_active_client_by_ft(buf_ft) for _, client in pairs(buf_clients) do if client.name ~= "null-ls" then table.insert(buf_client_names, client.name) end end - vim.list_extend(buf_client_names, active_client or {}) -- add formatter local formatters = require "lsp.null-ls.formatters" diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 27cec37c..a115bcc5 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -148,9 +148,9 @@ M.config = function() "Telescope lsp_workspace_diagnostics", "Workspace Diagnostics", }, - -- f = { "silent FormatWrite", "Format" }, f = { "lua vim.lsp.buf.formatting()", "Format" }, i = { "LspInfo", "Info" }, + I = { "LspInstallInfo", "Installer Info" }, j = { "lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})", "Next Diagnostic", -- cgit v1.2.3 From 47f68f4873471b515a5ee1800b287f929aac8641 Mon Sep 17 00:00:00 2001 From: Christian Chiarulli Date: Mon, 4 Oct 2021 07:15:26 +0000 Subject: feat: q quits lsp-installer (#1674) --- lua/core/autocmds.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lua/core') diff --git a/lua/core/autocmds.lua b/lua/core/autocmds.lua index 041926e5..662afcfa 100644 --- a/lua/core/autocmds.lua +++ b/lua/core/autocmds.lua @@ -13,6 +13,11 @@ lvim.autocommands = { "qf", "nnoremap q :q", }, + { + "FileType", + "lsp-installer", + "nnoremap q :q", + }, { "TextYankPost", "*", -- cgit v1.2.3 From 0ad60e90a9b0dd557df10f73bec344e88549a9d7 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 6 Oct 2021 02:07:23 +0330 Subject: [Feature] better code action prompt and auto show codelens actions (#1698) --- lua/core/telescope.lua | 20 ++++++++++++++++++++ lua/core/which-key.lua | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'lua/core') diff --git a/lua/core/telescope.lua b/lua/core/telescope.lua index eba27eec..0fb735fa 100644 --- a/lua/core/telescope.lua +++ b/lua/core/telescope.lua @@ -159,6 +159,26 @@ function M.view_lunarvim_changelog() }):find() end +function M.code_actions() + local opts = { + winblend = 15, + layout_config = { + prompt_position = "top", + width = 80, + height = 12, + }, + borderchars = { + prompt = { "─", "│", " ", "│", "╭", "╮", "│", "│" }, + results = { "─", "│", "─", "│", "├", "┤", "╯", "╰" }, + preview = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, + }, + border = {}, + previewer = false, + shorten_path = false, + } + require("telescope.builtin").lsp_code_actions(require("telescope.themes").get_dropdown(opts)) +end + function M.setup() local telescope = require "telescope" diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index a115bcc5..c9e9b2f4 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -139,7 +139,7 @@ M.config = function() l = { name = "LSP", - a = { "lua vim.lsp.buf.code_action()", "Code Action" }, + a = { "lua require('core.telescope').code_actions()", "Code Action" }, d = { "Telescope lsp_document_diagnostics", "Document Diagnostics", @@ -159,6 +159,7 @@ M.config = function() "lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})", "Prev Diagnostic", }, + l = { "lua vim.lsp.codelens.run()", "CodeLens Action" }, p = { name = "Peek", d = { "lua require('lsp.peek').Peek('definition')", "Definition" }, -- cgit v1.2.3 From c0e3c8d43ae6ca011e4036329ae31115957d1394 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Thu, 7 Oct 2021 17:47:53 +0200 Subject: feat(lsp): handle user configuration in setup() (#1707) --- lua/core/commands.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lua/core') diff --git a/lua/core/commands.lua b/lua/core/commands.lua index f732c9a2..6ceeaaff 100644 --- a/lua/core/commands.lua +++ b/lua/core/commands.lua @@ -11,8 +11,8 @@ M.defaults = { endfunction ]], -- :LvimInfo - [[command! LvimInfo lua require('core.info').toggle_popup(vim.bo.filetype)]], - [[ command! LvimCacheReset lua require('bootstrap').reset_cache() ]], + [[ command! LvimInfo lua require('core.info').toggle_popup(vim.bo.filetype) ]], + [[ command! LvimCacheReset lua require('utils.hooks').reset_cache() ]], [[ command! LvimUpdate lua require('bootstrap').update() ]], } -- cgit v1.2.3 From a814ea2e14792f542092f7428e7c5446b0908b03 Mon Sep 17 00:00:00 2001 From: Chris Dawkins Date: Fri, 8 Oct 2021 01:00:05 -0600 Subject: fix: correct variable names in NvimTree setup table (#1710) Co-authored-by: chris --- lua/core/nvimtree.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lua/core') diff --git a/lua/core/nvimtree.lua b/lua/core/nvimtree.lua index 8d3b1b6a..55cc6175 100644 --- a/lua/core/nvimtree.lua +++ b/lua/core/nvimtree.lua @@ -6,9 +6,9 @@ function M.config() active = true, on_config_done = nil, setup = { - auto_open = 0, + open_on_setup = 0, auto_close = 1, - tab_open = 0, + open_on_tab = 0, update_focused_file = { enable = 1, }, -- cgit v1.2.3 From 85e7b7804a2c9d6847ff978c82bb3a3ac16d757f Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Fri, 8 Oct 2021 22:24:55 +0330 Subject: fix: don't use the cmp floating window (#1715) --- lua/core/cmp.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lua/core') diff --git a/lua/core/cmp.lua b/lua/core/cmp.lua index 965285c7..b058bd6a 100644 --- a/lua/core/cmp.lua +++ b/lua/core/cmp.lua @@ -34,6 +34,10 @@ M.config = function() behavior = cmp.ConfirmBehavior.Replace, select = true, }, + experimental = { + ghost_text = false, + native_menu = true, + }, formatting = { kind_icons = { Class = " ", -- cgit v1.2.3 From e2df61f2565e2b1c16444b31e657f1f9df8e716b Mon Sep 17 00:00:00 2001 From: Xavier Young <45989017+younger-1@users.noreply.github.com> Date: Sat, 9 Oct 2021 13:55:45 +0800 Subject: fix(telescope): prompt position when find/grep LunarVim files (#1711) --- lua/core/telescope.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lua/core') diff --git a/lua/core/telescope.lua b/lua/core/telescope.lua index 0fb735fa..ba0a9ee1 100644 --- a/lua/core/telescope.lua +++ b/lua/core/telescope.lua @@ -26,7 +26,6 @@ function M.config() layout_strategy = "horizontal", layout_config = { width = 0.75, - prompt_position = "bottom", preview_cutoff = 120, horizontal = { mirror = false }, vertical = { mirror = false }, @@ -91,7 +90,7 @@ function M.find_lunarvim_files(opts) local theme_opts = themes.get_ivy { sorting_strategy = "ascending", layout_strategy = "bottom_pane", - prompt = ">> ", + prompt_prefix = ">> ", prompt_title = "~ LunarVim files ~", cwd = utils.join_paths(get_runtime_dir(), "lvim"), find_command = { "git", "ls-files" }, @@ -106,7 +105,7 @@ function M.grep_lunarvim_files(opts) local theme_opts = themes.get_ivy { sorting_strategy = "ascending", layout_strategy = "bottom_pane", - prompt = ">> ", + prompt_prefix = ">> ", prompt_title = "~ search LunarVim ~", cwd = utils.join_paths(get_runtime_dir(), "lvim"), } -- cgit v1.2.3 From b524100f016de6b934894547d48f9ef811902397 Mon Sep 17 00:00:00 2001 From: Luc Sinet Date: Sat, 9 Oct 2021 13:45:34 +0200 Subject: feat: support wildcard filetypes for null-ls providers (#1447) Co-authored-by: kylo252 <59826753+kylo252@users.noreply.github.com> --- lua/core/info.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lua/core') diff --git a/lua/core/info.lua b/lua/core/info.lua index ff024fa5..16001d07 100644 --- a/lua/core/info.lua +++ b/lua/core/info.lua @@ -11,6 +11,7 @@ local M = { local fmt = string.format local text = require "interface.text" +local lsp_utils = require "lsp.utils" local function str_list(list) return fmt("[ %s ]", table.concat(list, ", ")) @@ -67,7 +68,7 @@ local function tbl_set_highlight(terms, highlight_group) end local function make_client_info(client) - local client_enabled_caps = require("lsp.utils").get_ls_capabilities(client.id) + local client_enabled_caps = lsp_utils.get_client_capabilities(client.id) local name = client.name local id = client.id local document_formatting = client.resolved_capabilities.document_formatting @@ -89,8 +90,7 @@ local function make_client_info(client) end function M.toggle_popup(ft) - local lsp_utils = require "lsp.utils" - local clients = lsp_utils.get_active_client_by_ft(ft) + local clients = lsp_utils.get_active_clients_by_ft(ft) local client_names = {} local header = { -- cgit v1.2.3 From 82b7a35858479223c1e34bea2f64451ecf1e5f66 Mon Sep 17 00:00:00 2001 From: Chase Colman <5411+chase@users.noreply.github.com> Date: Sun, 10 Oct 2021 02:47:01 +0800 Subject: fix(cmp/autopairs): prevent out of bounds jump and re-enable jump after confirm (#1708) --- lua/core/autopairs.lua | 12 ++--- lua/core/cmp.lua | 128 +++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 116 insertions(+), 24 deletions(-) (limited to 'lua/core') diff --git a/lua/core/autopairs.lua b/lua/core/autopairs.lua index a67f3b07..eb080fb1 100644 --- a/lua/core/autopairs.lua +++ b/lua/core/autopairs.lua @@ -4,14 +4,8 @@ function M.config() lvim.builtin.autopairs = { active = true, on_config_done = nil, - ---@usage map on insert mode - map_cr = true, ---@usage auto insert after select function or method item map_complete = true, - ---@usage automatically select the first item - auto_select = true, - ---@usage use insert confirm behavior instead of replace - insert = false, ---@usage -- modifies the function or method delimiter by filetypes map_char = { all = "(", @@ -60,12 +54,12 @@ M.setup = function() if package.loaded["cmp"] then require("nvim-autopairs.completion.cmp").setup { - map_cr = lvim.builtin.autopairs.map_cr, + map_cr = false, map_complete = lvim.builtin.autopairs.map_complete, - auto_select = lvim.builtin.autopairs.auto_select, - insert = lvim.builtin.autopairs.insert, map_char = lvim.builtin.autopairs.map_char, } + -- we map CR explicitly in cmp.lua but we still need to setup the autopairs CR keymap + vim.api.nvim_set_keymap("i", "", "v:lua.MPairs.autopairs_cr()", { expr = true, noremap = true }) end require("nvim-treesitter.configs").setup { autopairs = { enable = true } } diff --git a/lua/core/cmp.lua b/lua/core/cmp.lua index b058bd6a..d5d92314 100644 --- a/lua/core/cmp.lua +++ b/lua/core/cmp.lua @@ -29,14 +29,106 @@ M.config = function() if not status_luasnip_ok then return end + local win_get_cursor = vim.api.nvim_win_get_cursor + local get_current_buf = vim.api.nvim_get_current_buf + + local function inside_snippet() + -- for outdated versions of luasnip + if not luasnip.session.current_nodes then + return false + end + + local node = luasnip.session.current_nodes[get_current_buf()] + if not node then + return false + end + + local snip_begin_pos, snip_end_pos = node.parent.snippet.mark:pos_begin_end() + local pos = win_get_cursor(0) + pos[1] = pos[1] - 1 -- LuaSnip is 0-based not 1-based like nvim for rows + return pos[1] >= snip_begin_pos[1] and pos[1] <= snip_end_pos[1] + end + + ---sets the current buffer's luasnip to the one nearest the cursor + ---@return boolean true if a node is found, false otherwise + local function seek_luasnip_cursor_node() + -- for outdated versions of luasnip + if not luasnip.session.current_nodes then + return false + end + + local pos = win_get_cursor(0) + pos[1] = pos[1] - 1 + local node = luasnip.session.current_nodes[get_current_buf()] + if not node then + return false + end + + local snippet = node.parent.snippet + local exit_node = snippet.insert_nodes[0] + + -- exit early if we're past the exit node + if exit_node then + local exit_pos_end = exit_node.mark:pos_end() + if (pos[1] > exit_pos_end[1]) or (pos[1] == exit_pos_end[1] and pos[2] > exit_pos_end[2]) then + snippet:remove_from_jumplist() + luasnip.session.current_nodes[get_current_buf()] = nil + + return false + end + end + + node = snippet.inner_first:jump_into(1, true) + while node ~= nil and node.next ~= nil and node ~= snippet do + local n_next = node.next + local next_pos = n_next and n_next.mark:pos_begin() + local candidate = n_next ~= snippet and next_pos and (pos[1] < next_pos[1]) + or (pos[1] == next_pos[1] and pos[2] < next_pos[2]) + + -- Past unmarked exit node, exit early + if n_next == nil or n_next == snippet.next then + snippet:remove_from_jumplist() + luasnip.session.current_nodes[get_current_buf()] = nil + + return false + end + + if candidate then + luasnip.session.current_nodes[get_current_buf()] = node + return true + end + + local ok + ok, node = pcall(node.jump_from, node, 1, true) -- no_move until last stop + if not ok then + snippet:remove_from_jumplist() + luasnip.session.current_nodes[get_current_buf()] = nil + + return false + end + end + + -- No candidate, but have an exit node + if exit_node then + -- to jump to the exit node, seek to snippet + luasnip.session.current_nodes[get_current_buf()] = snippet + return true + end + + -- No exit node, exit from snippet + snippet:remove_from_jumplist() + luasnip.session.current_nodes[get_current_buf()] = nil + return false + end + lvim.builtin.cmp = { confirm_opts = { behavior = cmp.ConfirmBehavior.Replace, - select = true, + select = false, }, experimental = { - ghost_text = false, - native_menu = true, + ghost_text = true, + native_menu = false, }, formatting = { kind_icons = { @@ -111,10 +203,12 @@ M.config = function() [""] = cmp.mapping.scroll_docs(4), -- TODO: potentially fix emmet nonsense [""] = cmp.mapping(function() - if vim.fn.pumvisible() == 1 then - vim.fn.feedkeys(T "", "n") - elseif luasnip.expand_or_jumpable() then - vim.fn.feedkeys(T "luasnip-expand-or-jump", "") + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expandable() then + luasnip.expand() + elseif inside_snippet() and seek_luasnip_cursor_node() and luasnip.jumpable() then + luasnip.jump(1) elseif check_backspace() then vim.fn.feedkeys(T "", "n") elseif is_emmet_active() then @@ -127,10 +221,10 @@ M.config = function() "s", }), [""] = cmp.mapping(function(fallback) - if vim.fn.pumvisible() == 1 then - vim.fn.feedkeys(T "", "n") - elseif luasnip.jumpable(-1) then - vim.fn.feedkeys(T "luasnip-jump-prev", "") + if cmp.visible() then + cmp.select_prev_item() + elseif inside_snippet() and luasnip.jumpable(-1) then + luasnip.jump(-1) else fallback() end @@ -142,12 +236,16 @@ M.config = function() [""] = cmp.mapping.complete(), [""] = cmp.mapping.close(), [""] = cmp.mapping(function(fallback) - if not require("cmp").confirm(lvim.builtin.cmp.confirm_opts) then - if luasnip.jumpable() then - vim.fn.feedkeys(T "luasnip-jump-next", "") - else + if cmp.visible() and cmp.confirm(lvim.builtin.cmp.confirm_opts) then + return + end + + if inside_snippet() and seek_luasnip_cursor_node() and luasnip.jumpable() then + if not luasnip.jump(1) then fallback() end + else + fallback() end end), }, -- cgit v1.2.3