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

Setup with nvim-lspconfig doesn't work #2

Closed
vuxuanhungg opened this issue Jul 9, 2023 · 4 comments
Closed

Setup with nvim-lspconfig doesn't work #2

vuxuanhungg opened this issue Jul 9, 2023 · 4 comments

Comments

@vuxuanhungg
Copy link

vuxuanhungg commented Jul 9, 2023

Using the provided nvim-lspconfig setup, I encoutered an error: [lspconfig] Cannot access configuration for emmet_language_server. Ensure this server is listed in 'server_configuration.md' or added as custom server.

Setup with autocmd does work though. However, I'd like the lsp stuffs being in a single place, so I prefer setting up with nvim-lspconfig.

I then came up with this config.

local lspconfig = require "lspconfig"
local configs = require "lspconfig.configs"

if not configs.emmet_language_server then
  configs.emmet_language_server = {
    default_config = {
      filetypes = {
        "html",
        "css",
        "scss",
        "javascript",
        "javascriptreact",
        "typescriptreact",
        "svelte",
      },
      cmd = { "emmet-language-server", "--stdio" },
      root_dir = lspconfig.util.root_pattern ".git",
      init_options = {
        --- @type table<string, any> https://docs.emmet.io/customization/preferences/
        preferences = {},
        --- @type "always" | "never" defaults to `"always"`
        showexpandedabbreviation = "always",
        --- @type boolean defaults to `true`
        showabbreviationsuggestions = true,
        --- @type boolean defaults to `false`
        showsuggestionsassnippets = false,
        --- @type table<string, any> https://docs.emmet.io/customization/syntax-profiles/
        syntaxprofiles = {},
        --- @type table<string, string> https://docs.emmet.io/customization/snippets/#variables
        variables = {},
        --- @type string[]
        excludelanguages = {},
      },
    },
  }
end

lspconfig.emmet_language_server.setup {
  on_attach = on_attach,
  capabilities = capabilities,
}

Anyway, it's still a lot nicer if I could set this up without having to manually add and explicitly pass default options.

@olrtg
Copy link
Owner

olrtg commented Jul 9, 2023

Hey @xuanhung1509 ! Quick question.. are you on some nvim distro? because some distros freeze their core deps for some time.. so maybe you don't have the commit that has the changes.

I'm currently not using lspconfig in my personal config but maybe will do it tomorrow!

@vuxuanhungg
Copy link
Author

yep, I'm using Nvchad fyi.

@olrtg
Copy link
Owner

olrtg commented Jul 10, 2023

Ok! so in the mean time make sure that you have the commit that adds the emmet_language_server package to lspconfig here https://github.com/neovim/nvim-lspconfig/commits/master

@vuxuanhungg
Copy link
Author

Thanks! It works now after updating to the latest commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants