diff options
| -rw-r--r-- | lua/lvim/core/terminal.lua | 16 | ||||
| -rw-r--r-- | lua/lvim/lsp/templates.lua | 4 | ||||
| -rw-r--r-- | lua/lvim/plugin-loader.lua | 5 | ||||
| -rw-r--r-- | lua/lvim/utils/hooks.lua | 23 | ||||
| -rw-r--r-- | tests/minimal_lsp.lua | 19 | 
5 files changed, 23 insertions, 44 deletions
| diff --git a/lua/lvim/core/terminal.lua b/lua/lvim/core/terminal.lua index c5d1ea04..441ab61e 100644 --- a/lua/lvim/core/terminal.lua +++ b/lua/lvim/core/terminal.lua @@ -50,25 +50,13 @@ M.setup = function()    local terminal = require "toggleterm"    terminal.setup(lvim.builtin.terminal) -  -- setup the default terminal so it's always reachable -  local default_term_opts = { -    cmd = lvim.builtin.terminal.shell, -    keymap = lvim.builtin.terminal.open_mapping, -    label = "Toggle terminal", -    count = 1, -    direction = lvim.builtin.terminal.direction, -    size = lvim.builtin.terminal.size, -  } -  if lvim.builtin.terminal.open_mapping then -    M.add_exec(default_term_opts) -  end -    for i, exec in pairs(lvim.builtin.terminal.execs) do      local opts = {        cmd = exec[1],        keymap = exec[2],        label = exec[3], -      count = i + 1, +      -- NOTE: unable to consistently bind id/count <= 9, see #2146 +      count = i + 100,        direction = exec[4] or lvim.builtin.terminal.direction,        size = lvim.builtin.terminal.size,      } diff --git a/lua/lvim/lsp/templates.lua b/lua/lvim/lsp/templates.lua index eb05615e..6608047d 100644 --- a/lua/lvim/lsp/templates.lua +++ b/lua/lvim/lsp/templates.lua @@ -42,6 +42,10 @@ end  ---The files are generated to a runtimepath: "$LUNARVIM_RUNTIME_DIR/site/after/ftplugin/template.lua"  ---@param servers_names table list of servers to be enabled. Will add all by default  function M.generate_templates(servers_names) +  for _, client in pairs(vim.lsp.get_active_clients()) do +    client:stop() +  end +    servers_names = servers_names or {}    Log:debug "Templates installation in progress" diff --git a/lua/lvim/plugin-loader.lua b/lua/lvim/plugin-loader.lua index c5220d59..0fbe9971 100644 --- a/lua/lvim/plugin-loader.lua +++ b/lua/lvim/plugin-loader.lua @@ -43,7 +43,9 @@ function plugin_loader.init(opts)      },    } -  vim.cmd [[autocmd User PackerComplete lua require('lvim.utils.hooks').run_on_packer_complete()]] +  if not in_headless then +    vim.cmd [[autocmd User PackerComplete lua require('lvim.utils.hooks').run_on_packer_complete()]] +  end  end  -- packer expects a space separated list @@ -113,7 +115,6 @@ function plugin_loader.sync_core_plugins()  end  function plugin_loader.ensure_installed() -  plugin_loader.cache_clear()    local all_plugins = _G.packer_plugins or plugin_loader.get_core_plugins()    Log:trace(string.format("Syncing core plugins: [%q]", table.concat(all_plugins, ", ")))    pcall_packer_command("install", all_plugins) diff --git a/lua/lvim/utils/hooks.lua b/lua/lvim/utils/hooks.lua index ab7dfacd..10c3eb20 100644 --- a/lua/lvim/utils/hooks.lua +++ b/lua/lvim/utils/hooks.lua @@ -5,33 +5,25 @@ local in_headless = #vim.api.nvim_list_uis() == 0  function M.run_pre_update()    Log:debug "Starting pre-update hook" -  if package.loaded["lspconfig"] then -    vim.cmd [[ LspStop ]] -  end  end  function M.run_pre_reload()    Log:debug "Starting pre-reload hook" -  if package.loaded["lspconfig"] then -    vim.cmd [[ LspStop ]] -  end  end  function M.run_on_packer_complete() -  require("lvim.plugin-loader").recompile() -  -- forcefully activate nvim-web-devicons -  require("nvim-web-devicons").set_up_highlights() -  if package.loaded["lspconfig"] then -    vim.cmd [[ LspStart ]] -  end +  -- manually trigger event to fix colors +  vim.cmd [[ doautocmd ColorScheme ]]    Log:info "Reloaded configuration"  end  function M.run_post_reload()    Log:debug "Starting post-reload hook" - -  M.reset_cache()    require("lvim.plugin-loader").ensure_installed() +  M.reset_cache() +  if package.loaded["lspconfig"] then +    pcall(vim.cmd, "LspRestart") +  end  end  ---Reset any startup cache files used by Packer and Impatient @@ -67,9 +59,6 @@ function M.run_post_update()        end        -- TODO: add a changelog        vim.notify("Update complete", vim.log.levels.INFO) -      if package.loaded["lspconfig"] then -        vim.cmd [[ LspStart ]] -      end      end)    end  end diff --git a/tests/minimal_lsp.lua b/tests/minimal_lsp.lua index 1c496c5a..660f824b 100644 --- a/tests/minimal_lsp.lua +++ b/tests/minimal_lsp.lua @@ -74,11 +74,12 @@ _G.load_config = function()      buf_set_keymap("n", "<space>lI", "<cmd>LspInstallInfo<CR>", opts)    end -  -- Add the server that troubles you here, e.g. "sumneko_lua", "pyright", "tsserver" -  local name = "clangd" +  -- Add the server that troubles you here, e.g. "clangd", "pyright", "tsserver" +  local name = "sumneko_lua" -  -- You need to specify the server's command manually -  local cmd +  local setup_opts = { +    on_attach = on_attach, +  }    if use_lsp_installer then      local server_available, server = require("nvim-lsp-installer.servers").get_server(name) @@ -86,22 +87,18 @@ _G.load_config = function()        server:install()      end      local default_opts = server:get_default_options() -    cmd = default_opts.cmd +    setup_opts.cmd_env = default_opts.cmd_env    end    if not name then      print "You have not defined a server name, please edit minimal_init.lua"    end -  if not nvim_lsp[name].document_config.default_config.cmd and not cmd then +  if not nvim_lsp[name].document_config.default_config.cmd and not setup_opts.cmd then      print [[You have not defined a server default cmd for a server        that requires it please edit minimal_init.lua]]    end -  nvim_lsp[name].setup { -    cmd = cmd, -    on_attach = on_attach, -  } - +  nvim_lsp[name].setup(setup_opts)    print [[You can find your log at $HOME/.cache/nvim/lsp.log. Please paste in a github issue under a details tag as described in the issue template.]]  end | 
