0

bashls is not working. I have multiple working servers with nvim-lspconfig yet I can't figure out how to make the bashls server work at any capacity.

I've tried this

            ... other lsps ...
            rust_analyzer = {},
            dockerls = {},
            bashls = {
               cmd = { "bash-language-server", "start" },
               filetypes = { "sh", "bash" }
            },
            tsserver = {},
            volar = {},
            lemminx = {},

            ... other lsps ...

and also with only

bashls = {}, 

I already ran

pnpm i -g bash-language-server

and restarted the machine, too.

I'm not aware of any other required configuration. I've so far done the same process I follow for any language server, but this one refuses to work. Any ideas? I am using lazy/lazy.nvim for package management.

Here is my full lspconfig plugin configuration

return {
'neovim/nvim-lspconfig',
event = { 'BufReadPre', 'BufNewFile' },
dependencies = {
    { 'williamboman/mason.nvim', opts = {} },
    { 'folke/neodev.nvim',       opts = {} },
    { 'j-hui/fidget.nvim',       opts = {},       tag = 'legacy' },
    { 'folke/neoconf.nvim',      cmd = "Neoconf", config = true },
    'williamboman/mason-lspconfig.nvim',
},
config = function()
    local on_attach = function(_, bufnr)
        local nmap = function(keys, func, desc)
            if desc then
                desc = 'LSP: ' .. desc
            end

            vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
        end
        nmap('<leader>lr', vim.lsp.buf.rename, '[r] Rename')
        nmap('<leader>la', vim.lsp.buf.code_action, '[r] Code Action')
        nmap('<leader>lD', vim.lsp.buf.declaration, '[D] Go to declaration')
        nmap('<leader>ld', vim.lsp.buf.definition, '[d] Go to definition')
        nmap('<leader>lT', vim.lsp.buf.type_definition, '[T] Type definition')
        nmap('<leader>g', require('telescope.builtin').lsp_references, '[g] Go to references')
        nmap('<leader>li', vim.lsp.buf.implementation, '[i] Go to implementation')
        nmap('<leader>ls', require('telescope.builtin').lsp_document_symbols, '[s] Document symbols')
        nmap('<leader>lw', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[w] Workspace symbols')
        nmap('<leader>lh', vim.lsp.buf.hover, '[h] Hover Documentation')
        nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
        vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
            vim.lsp.buf.format()
        end, { desc = 'Format current buffer' })
    end
    local servers = {
        omnisharp = {
            cmd = { "dotnet", "/usr/local/bin/omnisharp/OmniSharp.dll" },
            enable_editorconfig_support = true,
            enable_ms_build_load_projects_on_demand = false,
            enable_roslyn_analyzers = true,
            organize_imports_on_format = true,
            enable_import_completion = false,
            sdk_include_prereleases = true,
            analyze_open_documents_only = false,
        },
        rust_analyzer = {},
        dockerls = {},
        bashls = {
            cmd = { "bash-language-server", "start" },
            filetypes = { "sh", "bash" }
        },
        tsserver = {},
        volar = {},
        lemminx = {},
        html = {},
        jsonls = {},
        cssls = {},
        tailwindcss = {},
        pylsp = {},
        sqlls = {},
        gradle_ls = {},
        kotlin_language_server = {},
        lua_ls = {
            Lua = {
                workspace = { checkThirdParty = false },
                telemetry = { enable = false },
                globals = { 'vim' },
            },
        },
    }
    local capabilities = vim.lsp.protocol.make_client_capabilities()
    capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
    local mason_lspconfig = require 'mason-lspconfig'
    mason_lspconfig.setup {
        ensure_installed = vim.tbl_keys(servers),
    }
    mason_lspconfig.setup_handlers {
        function(server_name)
            require('lspconfig')[server_name].setup {
                capabilities = capabilities,
                on_attach = on_attach,
                settings = servers[server_name],
            }
        end,
    }
end
}
1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.