Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autostart=false doesn't have any effect #3519

Open
kStor2poche opened this issue Dec 20, 2024 · 0 comments
Open

autostart=false doesn't have any effect #3519

kStor2poche opened this issue Dec 20, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@kStor2poche
Copy link

kStor2poche commented Dec 20, 2024

Of course I did not find anyone having this exact issue online (but I found plenty cases of the opposite happening, quite ironically x) )

Description

Hi,

I tried for some time to get ltex-ls to not autostart on my config, without success. While I first thought that this was due to ltex plugin "barreiroleo/ltex-extra.nvim" being present, I found out after some troubleshooting that this was the case for other "bare" LSPs such as lua_ls.

And this is despite LspInfo reporting that autostart is indeed set to false :

lspconfig: require("lspconfig.health").check()

LSP configs active in this session (globally) ~
- Configured servers: jdtls, basedpyright, clangd, dockerls, docker_compose_language_service, cssls, intelephense, spectral, rust_analyzer, glsl_analyzer, lua_ls, ltex, arduino_language_server, bashls, omnisharp, asm_lsp, denols
- OK Deprecated servers: (none)

LSP configs active in this buffer (bufnr: 1) ~
- Language client log: ~/.local/state/nvim/lsp.log
- Detected filetype: `markdown`
- 1 client(s) attached to this buffer
- Client: `ltex` (id: 1, bufnr: [1])
  root directory:    Running in single file mode.
  filetypes:         latex, tex, bib, markdown
  cmd:               ~/ltex-ls
  version:           `"ltex-ls": "16.0.0",`
  executable:        true
  autostart:         false

Docs for active configs: ~
[...]

Here is my lsp config for reference

--
-- setup LSP list
--
local helpers = require("helpers")

-- all config "presets" flavors
local default_config = {"clangd", "jdtls", "basedpyright", "bashls", "dockerls", "docker_compose_language_service", "arduino_language_server", "cssls","intelephense","spectral","rust_analyzer", "glsl_analyzer"}
local root_dir_config = {"omnisharp", "asm_lsp", "denols"}
local other_config = {"lua_ls", "ltex"}

local lsp_list = helpers.table_cat(helpers.table_cat(default_config, root_dir_config), other_config)
local lspconfig = require("lspconfig")

--
-- mason config
--
require("mason").setup({
    ui = {
        check_outdated_packages_on_open = true,
        border = "none",
        icons = {
            package_installed = "",
            package_pending = "",
            package_uninstalled = ""
        }
    }
})

--
-- mason-lspconfig config
--
require("mason-lspconfig").setup({
    ensure_installed = lsp_list,
    automatic_installation = false,
})

-- setup capabilities and on_attach according to what nvim_cmp can do
local capabilities = require('cmp_nvim_lsp').default_capabilities()
local on_attach = function(client, bufnr)
    -- Mappings.
    -- See `:help vim.lsp.*` for documentation on any of the below functions
    local bufopts = { noremap = true, silent = true, buffer = bufnr }
    vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
    vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
    vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
    vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
    vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
    vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
    vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
    vim.keymap.set('n', '<space>wl', function()
        print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
    end, bufopts)
    vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
    vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
    -- Apply action when "fix available" from lsp
    vim.keymap.set('n', '<leader>a', vim.lsp.buf.code_action, bufopts)
    vim.keymap.set('n', 'gr', require("telescope.builtin").lsp_references, bufopts)
    vim.keymap.set('n', '<space>F', function() vim.lsp.buf.format { async = true } end, bufopts)
    -- Cycle through code diagnostics
    vim.keymap.set('n', '<leader>o', '<cmd>lua vim.diagnostic.open_float()<CR>', bufopts)
    vim.keymap.set('n', '<leader>[', '<cmd>lua vim.diagnostic.goto_prev()<CR>', bufopts)
    vim.keymap.set('n', '<leader>]', '<cmd>lua vim.diagnostic.goto_next()<CR>', bufopts)
end

--
-- Sugar
--
local _border = "none"

vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
    vim.lsp.handlers.hover, {
        border = _border
    }
)

vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
    vim.lsp.handlers.signature_help, {
        border = _border
    }
)

vim.diagnostic.config{
    float={border=_border}
}


--
-- activate LSPs...
--

-- ... with a default configuration ...
for _,lsp in ipairs(default_config) do
    lspconfig[lsp].setup{ capabilities = capabilities, on_attach = on_attach }
end

-- ... specify the root directory for those that need it ...
for _,lsp in ipairs(root_dir_config) do
    lspconfig[lsp].setup{ root_dir = function() return vim.loop.cwd() end }
end

-- and provide special care for some :)
lspconfig.ltex.setup({
    capabilities = capabilities,
    on_attach = function(client, bufnr)
        on_attach(client, bufnr)
        require("ltex_extra").setup({
            path = vim.fn.expand("~") .. "/.local/share/ltex"
        })
    end,
    autostart = false,
    window_border = _border,
    filetypes = { "latex", "tex", "bib", "markdown" },
    settings = {
        ltex = {
            language = "auto",
            --disabledRules = { ["fr"] = { "MORFOLOGIK_RULE_FR_FR" }, },
            --dictionary = { ["fr"] = { "Dummy0", "Dummy1", "Dummy2", "Dummy3", "Dummy4", "Dummy5" } },
        },
    },
})

lspconfig.lua_ls.setup({
    capabilities = capabilities,
    on_attach = on_attach,
    autostart = false,
    settings = {
        Lua = {
            runtime = {
                -- Tell the language server which version of Lua you're using
                -- (most likely LuaJIT in the case of Neovim)
                version = 'LuaJIT',
            },
            diagnostics = {
                -- Get the language server to recognize the `vim` global
                globals = { 'vim', 'require' },
            },
            workspace = {
                -- Make the server aware of Neovim runtime files
                library = vim.api.nvim_get_runtime_file("", true),
                checkThirdParty = false, -- to avoid having the "do you want to use the luassert environment" every time
            },
            -- Do not send telemetry data containing a randomized but unique identifier
            telemetry = { enable = false, },
        },
    },
})

lspconfig.omnisharp.setup({
    capabilities = capabilities,
    on_attach = on_attach,
    enable_editorconfig_support = true,
    enable_ms_build_load_projects_on_demand = false,
    enable_roslyn_analyzers = true,
    enable_import_completion = true,
    handlers = {
        ["textDocument/definition"] = require('omnisharp_extended').handler,
    },
    cmd = { "omnisharp", '--languageserver', '--hostPID', tostring(vim.fn.getpid()) },
})

lspconfig.clangd.setup({
    capabilities = capabilities,
    on_attach = on_attach,
    cmd = { "clangd", "--fallback-style=UseTab: Never", "--fallback-style=IndentWidth: 4", "--fallback-style=TabWidth: 4"},
})
@kStor2poche kStor2poche added the bug Something isn't working label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant