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

How to config language servers like glsl-analyzer which is not managed by mason.nvim? #1149

Closed
2 tasks done
Penguin-SAMA opened this issue Jan 11, 2024 · 16 comments
Closed
2 tasks done
Labels
educational Issues that contain useful content good-first-issue Good for newcomers lsp LSP related issues usage User-specific issues

Comments

@Penguin-SAMA
Copy link

Version confirmation

  • Confirm

Following prerequisites

  • Confirm

Neovim version

NVIM v0.9.5

Branch info

main (Default/Latest)

Minimal (user) folder structure required to reproduce the issue

user/configs/lsp-servers/glsl-analyzer.lua
user/configs/lsp-servers/glslls.lua

Minimal config with steps on how to reproduce the issue

this the config on user/configs/lsp-servers/glsl-analyzer.lua
image

this the config on user/configs/lsp-servers/glslls.lua
image

Expected behavior

the config file seem not to be loaded

Additional information

this is :LspInfo
image

@Penguin-SAMA Penguin-SAMA added the usage User-specific issues label Jan 11, 2024
@Penguin-SAMA
Copy link
Author

and when i use TSUninstall glsl

image

@CharlesChiuGit
Copy link
Collaborator

CharlesChiuGit commented Jan 11, 2024

bruh, TSUninstall is for treesitter parsers.
glsl-analyzer and glslls are language servers.

did u state those LS in the config or install them manually yet?

@CharlesChiuGit CharlesChiuGit added invalid:misc Config independent issue and removed usage User-specific issues labels Jan 11, 2024
@Penguin-SAMA
Copy link
Author

did u state those LS in the config or install them manually yet?

i only use :TSInstall glsl, and created the two files mentioned above. Is there anything else that needs to be stated?

@CharlesChiuGit
Copy link
Collaborator

CharlesChiuGit commented Jan 11, 2024

i not familiar with glslls or glsl-analyzer, but i think :TSInstall glsl can only give u syntax highlighting, not the LS itself.
check this:
https://github.com/nvim-treesitter/nvim-treesitter#supported-languages
https://github.com/theHamsta/tree-sitter-glsl
glsl from :TSInstall glsl:

This is a extension of tree-sitter-c to support the syntax of GLSL (https://www.khronos.org/opengl/wiki/Core_Language_(GLSL)).

Since Mason doesn't have glslls and glsl-analyzer, u need to download/compile them by yourself and add them to your PATH.
https://github.com/nolanderc/glsl_analyzer#installation
https://github.com/svenstaro/glsl-language-server#compile

@Penguin-SAMA
Copy link
Author

Penguin-SAMA commented Jan 11, 2024

I found this in the README of glsl_analyzer, but I don't know how to add it to nvimdots. I don't want to modify the default init.lua

I have installed glsl-analyzer and confirmed that it is functional. Also, I added the 'glsl_analyzer' option to ['lsp_deps'] in settings.lua.

@CharlesChiuGit
Copy link
Collaborator

CharlesChiuGit commented Jan 11, 2024

Since glsl_analyzer is not in mason-registry, u dont need to add it to [lsp_deps].

u also need to make a custom lspconfig entry for glsl_analuzer like this:

-- Setup lsps that are not supported by `mason.nvim` but supported by `nvim-lspconfig` here.
if vim.fn.executable("dart") == 1 then
local ok, _opts = pcall(require, "user.configs.lsp-servers.dartls")
if not ok then
_opts = require("completion.servers.dartls")
end
local final_opts = vim.tbl_deep_extend("keep", _opts, opts)
nvim_lsp.dartls.setup(final_opts)
end

@Penguin-SAMA
Copy link
Author

like this?

if vim.fn.executable("glsl-analyzer") == 1 then
		local glsl_opts = {
			-- 在这里放置 glsl-analyzer 的特定配置选项
		}
		local final_glsl_opts = vim.tbl_deep_extend("keep", glsl_opts, opts)
		nvim_lsp.glsl_analyzer.setup(final_glsl_opts)
	end

@CharlesChiuGit
Copy link
Collaborator

yeap

@Penguin-SAMA
Copy link
Author

But it still doesn't work, the .vert files don't have any language server functionality.
image
image

@CharlesChiuGit
Copy link
Collaborator

CharlesChiuGit commented Jan 11, 2024

can u call glsl-analyzer from any path? or just the folder where u installed it?

or can u show us your whole config?

@Penguin-SAMA
Copy link
Author

i can call glsl-analyzer any path.
What configuration files do I need to send?

@Penguin-SAMA
Copy link
Author

Also, I found that glsl-analyzer seems to require the vim-glsl plugin, but even after installing the vim-glsl plugin, it's not effective.

@Penguin-SAMA
Copy link
Author

Penguin-SAMA commented Jan 11, 2024

Oh, I think I understand now. vim-glsl is written in Vimscript, and it requires running the following statement:path

" Language: OpenGL Shading Language
" Maintainer: Sergii Tykhomyrov <sergii@tykhomyrov.net>

" Extensions supported by Khronos reference compiler (with one exception, ".glsl")
" https://github.com/KhronosGroup/glslang
autocmd! BufNewFile,BufRead *.vert,*.tesc,*.tese,*.glsl,*.geom,*.frag,*.comp,*.rgen,*.rmiss,*.rchit,*.rahit,*.rint,*.rcall set filetype=glsl

" vim:set sts=2 sw=2 :

And my user/plugins/vim-glsl.lua is as follows:
image
If I use :set=glsl in any file, both vim-glsl and glsl-analyzer work fine.
But I don't know how to modify my vim-glsl.lua. Please help me.

@ayamir
Copy link
Owner

ayamir commented Jan 12, 2024

  1. Create lua/user/configs/lsp.lua:
local nvim_lsp = require("lspconfig")
local opts = {
	capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()),
}
-- Setup lsps that are not supported by `mason.nvim` but supported by `nvim-lspconfig` here.
if vim.fn.executable("glsl_analyzer") == 1 then
	local ok, _opts = pcall(require, "user.configs.lsp-servers.glsl_analyzer")
	if ok then
		local final_opts = vim.tbl_deep_extend("keep", _opts, opts)
		nvim_lsp.glsl_analyzer.setup(final_opts)
	end
end
  1. Create lua/user/configs/lsp-servers/glsl_analyzer.lua
return {
	default_config = {
		cmd = { "glsl_analyzer" },
		filetypes = { "glsl", "vert", "tesc", "tese", "frag", "geom", "comp" },
		single_file_support = true,
	},
	docs = {
		description = [[
https://github.com/nolanderc/glsl_analyzer

Language server for GLSL
    ]],
	},
}
  1. create file lua/user/plugins/lang.lua.
local lang = {}

lang["tikhomirov/vim-glsl"] = {
	lazy = true,
	ft = { "glsl", "vert", "tesc", "tese", "frag", "geom", "comp" },
}

return lang

then all be fine.

  1. Open a glsl or vert file:

image

image

@CharlesChiuGit
Copy link
Collaborator

CharlesChiuGit commented Jan 12, 2024

damn @ayamir that's what i'm drafting lol.

@ayamir ayamir added good-first-issue Good for newcomers lsp LSP related issues usage User-specific issues educational Issues that contain useful content and removed invalid:misc Config independent issue labels Jan 12, 2024
@CharlesChiuGit CharlesChiuGit changed the title glsl-languages-server doesn't work How to config certain language server like glsl-analyzer which is not managed by mason.nvim? Jan 12, 2024
@CharlesChiuGit CharlesChiuGit changed the title How to config certain language server like glsl-analyzer which is not managed by mason.nvim? How to config language servers like glsl-analyzer which is not managed by mason.nvim? Jan 12, 2024
@Penguin-SAMA
Copy link
Author

This is so cool! Thank you for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
educational Issues that contain useful content good-first-issue Good for newcomers lsp LSP related issues usage User-specific issues
Projects
None yet
Development

No branches or pull requests

3 participants