hyprland-community / hyprls

A LSP server for Hyprland config files [maintainer=@ewen-lbh]
https://ewen.works/hyprls
MIT License
129 stars 7 forks source link

how to setup `hyprls` with `lspconfig`? #11

Closed daUnknownCoder closed 5 months ago

daUnknownCoder commented 5 months ago

i use this in my init.lua:

vim.filetype.add({
  pattern = { [".*/hypr/.*%.conf"] = "hyprlang" },
})

which works for my hyprlang treesitter parser

im not sure how to use hyprls in lspconfig like the others: something like:

      lspconfig["hyprls"].setup({
        capabilities = capabilities,
        on_attach = on_attach,
      })

installation requires just not sure why i need it tho

in this pattern, can i not use hyprlang?

-- Hyprlang LSP
vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter'}, {
        pattern = {"*.hl", "hypr*.conf"},
        callback = function(event)
                print(string.format("starting hyprls for %s", vim.inspect(event)))
                vim.lsp.start {
                        name = "hyprlang",
                        cmd = {"hyprls"},
                        root_dir = vim.fn.getcwd(),
                }
        end
})

also in the blog, you have the color picker and a ⭐, which looks like a plugin, mind if you tell me what is it?

image

is it neovim?

ewen-lbh commented 5 months ago

Hi! I actually did a PR for lspconfig to include hyprls (see https://github.com/neovim/nvim-lspconfig/pull/3137) but it's misconfigured: I mistook filetypes for file name patterns...

However someone fixed my mistake lmao, thx @mehalter

So the lspconfig should work if the hyprlang filetype is defined

The installation does not require Just, this is required to build from source. Just is a modern alternative to Makefiles.

You can install with go.

Having HyprLS available in linux repos would be nice, but I don't really have the time to setup all of that up. I kinda did set that up for ortfo/db so I could do it eventually but I don't really have the time right now.

Lastly, the color picker is indeed using the color features of the LSP standard, but the screenshot comes from VSCode. I don't really know if neovim has an equivalent feature, some plugin may be able to tap into the LSP color features.

The star emoji has nothing to do with LSPs, I think it's copilot? not rly sure tbh.

And it the autocmd is kind of a dirty hack (see #9), so changing the readme might be a good idea.

Feel free to re-open the issue if this doesn't answer what you asked