revert: automatically restart lsp server (#128)

semi revert of 7c198a1b36
This commit is contained in:
Oleksandr Smirnov 2025-11-25 17:02:38 +02:00 committed by GitHub
parent f599e75963
commit 7764f6e37f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 0 additions and 31 deletions

View file

@ -219,9 +219,6 @@ require("gopher").setup {
-- timeout for running installer commands(e.g :GoDepsInstall, :GoDepsInstallSync) -- timeout for running installer commands(e.g :GoDepsInstall, :GoDepsInstallSync)
installer_timeout = 999999, installer_timeout = 999999,
-- restart gopls server after commands like `:GoMod`, `:GoGet`, `:GoWork`
restart_lsp = false,
-- user specified paths to binaries -- user specified paths to binaries
commands = { commands = {
go = "go", go = "go",

View file

@ -61,9 +61,6 @@ or use `require("gopher").install_deps()` if you prefer lua api.
---@type number ---@type number
installer_timeout = 999999, installer_timeout = 999999,
-- restart gopls server after commands like `:GoMod`, `:GoGet`, `:GoWork`
restart_lsp = false,
-- user specified paths to binaries -- user specified paths to binaries
---@class gopher.ConfigCommand ---@class gopher.ConfigCommand
commands = { commands = {

View file

@ -1,11 +0,0 @@
local lsp = {}
local gopls = "gopls"
-- Restarts gopls server (see: `:h lsp-restart`)
function lsp.restart()
vim.lsp.enable(gopls, false)
vim.lsp.enable(gopls, true)
end
return lsp

View file

@ -33,9 +33,6 @@ local default_config = {
---@type number ---@type number
installer_timeout = 999999, installer_timeout = 999999,
-- restart gopls server after commands like `:GoMod`, `:GoGet`, `:GoWork`
restart_lsp = false,
-- user specified paths to binaries -- user specified paths to binaries
---@class gopher.ConfigCommand ---@class gopher.ConfigCommand
commands = { commands = {
@ -101,7 +98,6 @@ function config.setup(user_config)
vim.validate("log_level", _config.log_level, "number") vim.validate("log_level", _config.log_level, "number")
vim.validate("timeout", _config.timeout, "number") vim.validate("timeout", _config.timeout, "number")
vim.validate("installer_timeout", _config.timeout, "number") vim.validate("installer_timeout", _config.timeout, "number")
vim.validate("restart_lsp", _config.restart_lsp, "boolean")
vim.validate("commands", _config.commands, "table") vim.validate("commands", _config.commands, "table")
vim.validate("commands.go", _config.commands.go, "string") vim.validate("commands.go", _config.commands.go, "string")
vim.validate("commands.gomodifytags", _config.commands.gomodifytags, "string") vim.validate("commands.gomodifytags", _config.commands.gomodifytags, "string")

View file

@ -1,6 +1,5 @@
local c = require "gopher.config" local c = require "gopher.config"
local u = require "gopher._utils" local u = require "gopher._utils"
local lsp = require "gopher._utils.lsp"
local r = require "gopher._utils.runner" local r = require "gopher._utils.runner"
local go = {} local go = {}
@ -14,12 +13,6 @@ local function run(subcmd, args)
return rs.stdout return rs.stdout
end end
local function restart_lsp()
if c.restart_lsp then
lsp.restart()
end
end
---@param args string[] ---@param args string[]
function go.get(args) function go.get(args)
for i, arg in ipairs(args) do for i, arg in ipairs(args) do
@ -29,13 +22,11 @@ function go.get(args)
end end
run("get", args) run("get", args)
restart_lsp()
end end
---@param args string[] ---@param args string[]
function go.mod(args) function go.mod(args)
run("mod", args) run("mod", args)
restart_lsp()
end end
---@param args string[] ---@param args string[]
@ -43,7 +34,6 @@ function go.work(args)
-- TODO: use `gopls.tidy` -- TODO: use `gopls.tidy`
run("work", args) run("work", args)
restart_lsp()
end end
---Executes `go generate` ---Executes `go generate`