Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into nenikitov/main
Browse files Browse the repository at this point in the history
* origin/main:
  feat: Add regal lsp support (OPA rego linter) (williamboman#426)
  tests: add nvim v0.10.1 and v0.10.1 to test matrix (williamboman#446)
  docs: auto-generate available LSP servers list in readme (williamboman#445)
  feat: add steep configuration (williamboman#422)
  chore: update generated code (williamboman#441)
  chore: update generated code (williamboman#439)
  • Loading branch information
williamboman committed Aug 4, 2024
2 parents 195d36c + 5716924 commit 3ce7e05
Show file tree
Hide file tree
Showing 10 changed files with 399 additions and 234 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/autogenerate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: v0.9.0
version: v0.10.1

- name: make generate
run: make generate
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-generated-code-state.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: v0.9.0
version: v0.10.1

- name: make generate
run: make generate
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stylua.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
# CLI arguments
args: --check .
version: 0.18.0
version: 0.20.0
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
- v0.9.2
- v0.9.4
- v0.9.5
- v0.10.0
- v0.10.1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
496 changes: 277 additions & 219 deletions README.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions doc/mason-lspconfig-mapping.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ quick-lint-js quick_lint_js
r-languageserver r_language_server
raku-navigator raku_navigator
reason-language-server reason_ls
regal regal
regols regols
remark-language-server remark_ls
rescript-language-server rescriptls
Expand Down Expand Up @@ -177,6 +178,7 @@ sqlls sqlls
sqls sqls
standardrb standardrb
starlark-rust starlark_rust
steep steep
stimulus-language-server stimulus_ls
stylelint-lsp stylelint_lsp
svelte-language-server svelte
Expand Down
2 changes: 2 additions & 0 deletions doc/server-mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
| [r_language_server](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#r_language_server) | [r-languageserver](https://mason-registry.dev/registry/list#r-languageserver) |
| [raku_navigator](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#raku_navigator) | [raku-navigator](https://mason-registry.dev/registry/list#raku-navigator) |
| [reason_ls](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#reason_ls) | [reason-language-server](https://mason-registry.dev/registry/list#reason-language-server) |
| [regal](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#regal) | [regal](https://mason-registry.dev/registry/list#regal) |
| [regols](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#regols) | [regols](https://mason-registry.dev/registry/list#regols) |
| [remark_ls](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#remark_ls) | [remark-language-server](https://mason-registry.dev/registry/list#remark-language-server) |
| [rescriptls](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rescriptls) | [rescript-language-server](https://mason-registry.dev/registry/list#rescript-language-server) |
Expand Down Expand Up @@ -173,6 +174,7 @@
| [sqls](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sqls) | [sqls](https://mason-registry.dev/registry/list#sqls) |
| [standardrb](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#standardrb) | [standardrb](https://mason-registry.dev/registry/list#standardrb) |
| [starlark_rust](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#starlark_rust) | [starlark-rust](https://mason-registry.dev/registry/list#starlark-rust) |
| [steep](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#steep) | [steep](https://mason-registry.dev/registry/list#steep) |
| [stimulus_ls](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#stimulus_ls) | [stimulus-language-server](https://mason-registry.dev/registry/list#stimulus-language-server) |
| [stylelint_lsp](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#stylelint_lsp) | [stylelint-lsp](https://mason-registry.dev/registry/list#stylelint-lsp) |
| [svelte](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#svelte) | [svelte-language-server](https://mason-registry.dev/registry/list#svelte-language-server) |
Expand Down
13 changes: 7 additions & 6 deletions lua/mason-lspconfig/mappings/filetype.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ return {
erb = { "tailwindcss" },
erg = { "erg_language_server" },
erlang = { "elp", "erlangls" },
eruby = { "emmet_language_server", "emmet_ls", "stimulus_ls", "tailwindcss" },
eruby = { "emmet_language_server", "emmet_ls", "steep", "stimulus_ls", "tailwindcss" },
fennel = { "fennel_language_server", "fennel_ls" },
flux = { "flux_lsp" },
foam = { "foam_ls" },
Expand All @@ -71,7 +71,7 @@ return {
fsharp = { "fsautocomplete" },
genie = { "vala_ls" },
geom = { "glsl_analyzer", "glslls" },
gitcommit = { "ltex" },
gitcommit = { "harper_ls", "ltex" },
glsl = { "glsl_analyzer", "glslls" },
go = { "ast_grep", "golangci_lint_ls", "gopls", "harper_ls", "snyk_ls" },
gohtml = { "tailwindcss" },
Expand All @@ -89,12 +89,13 @@ return {
heex = { "elixirls", "lexical", "tailwindcss" },
helm = { "helm_ls", "snyk_ls" },
hoon = { "hoon_ls" },
html = { "angularls", "antlersls", "ast_grep", "emmet_language_server", "emmet_ls", "html", "htmx", "ltex", "lwc_ls", "stimulus_ls", "tailwindcss", "unocss" },
html = { "angularls", "antlersls", "ast_grep", "emmet_language_server", "emmet_ls", "harper_ls", "html", "htmx", "ltex", "lwc_ls", "stimulus_ls", "tailwindcss", "unocss" },
["html-eex"] = { "tailwindcss" },
["html.handlebars"] = { "glint" },
htmlangular = { "angularls", "emmet_language_server", "emmet_ls", "tailwindcss" },
htmldjango = { "emmet_language_server", "emmet_ls", "tailwindcss" },
jade = { "tailwindcss" },
java = { "ast_grep", "java_language_server", "jdtls" },
java = { "ast_grep", "harper_ls", "java_language_server", "jdtls" },
javascript = { "ast_grep", "biome", "cssmodules_ls", "denols", "dprint", "ember", "eslint", "glint", "harper_ls", "lwc_ls", "quick_lint_js", "rome", "snyk_ls", "sourcery", "stylelint_lsp", "tailwindcss", "tsserver", "vtsls" },
["javascript.glimmer"] = { "ember", "glint" },
["javascript.jsx"] = { "denols", "eslint", "tsserver", "vtsls" },
Expand Down Expand Up @@ -167,15 +168,15 @@ return {
raku = { "raku_navigator" },
razor = { "tailwindcss" },
reason = { "ocamllsp", "reason_ls", "tailwindcss" },
rego = { "regols" },
rego = { "regal", "regols" },
requirements = { "snyk_ls" },
rescript = { "rescriptls", "tailwindcss", "unocss" },
rmd = { "ltex", "r_language_server" },
rnoweb = { "ltex" },
robot = { "robotframework_ls" },
roslyn = { "dprint" },
rst = { "esbonio", "ltex" },
ruby = { "harper_ls", "rubocop", "ruby_lsp", "solargraph", "sorbet", "standardrb", "stimulus_ls" },
ruby = { "harper_ls", "rubocop", "ruby_lsp", "solargraph", "sorbet", "standardrb", "steep", "stimulus_ls" },
rust = { "ast_grep", "dprint", "harper_ls", "rust_analyzer" },
sass = { "emmet_language_server", "emmet_ls", "somesass_ls", "tailwindcss" },
scss = { "css_variables", "cssls", "emmet_language_server", "emmet_ls", "somesass_ls", "stylelint_lsp", "tailwindcss" },
Expand Down
2 changes: 2 additions & 0 deletions lua/mason-lspconfig/mappings/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ M.lspconfig_to_package = {
["raku_navigator"] = "raku-navigator",
["reason_ls"] = "reason-language-server",
["regols"] = "regols",
["regal"] = "regal",
["remark_ls"] = "remark-language-server",
["rescriptls"] = "rescript-language-server",
["rnix"] = "rnix-lsp",
Expand Down Expand Up @@ -177,6 +178,7 @@ M.lspconfig_to_package = {
["sqls"] = "sqls",
["standardrb"] = "standardrb",
["starlark_rust"] = "starlark-rust",
["steep"] = "steep",
["stimulus_ls"] = "stimulus-language-server",
["stylelint_lsp"] = "stylelint-lsp",
["svelte"] = "svelte-language-server",
Expand Down
110 changes: 104 additions & 6 deletions scripts/lua/mason-scripts/mason-lspconfig/generate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ local Optional = require "mason-core.optional"

local _ = require "mason-core.functional"
local a = require "mason-core.async"
local fs = require "mason-core.fs"
local lspconfig = require "lspconfig"
local lspconfig_server_mapping = require "mason-lspconfig.mappings.server"
local path = require "mason-core.path"
local script_utils = require "mason-scripts.utils"

local DOCS_DIR = path.concat { vim.loop.cwd(), "doc" }
local MASON_LSPCONFIG_DIR = path.concat { vim.loop.cwd(), "lua", "mason-lspconfig" }
local DOCS_DIR = "doc"
local MASON_LSPCONFIG_DIR = path.concat { "lua", "mason-lspconfig" }

require("mason").setup()
require("mason-registry").refresh()
Expand Down Expand Up @@ -50,21 +51,21 @@ local function ensure_valid_package_name_translations()
end
end

local get_lspconfig_url =
_.format "https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#%s"

local get_server_mappings = _.compose(
_.filter_map(function(pair)
local lspconfig_name, mason_name =
assert(pair[1], "missing lspconfig name"), assert(pair[2], "missing mason name")
if not pcall(require, ("lspconfig.server_configurations.%s"):format(lspconfig_name)) then
return Optional.empty()
end
local lspconfig_url = ("https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#%s"):format(
lspconfig_name
)
local mason_url = ("https://mason-registry.dev/registry/list#%s"):format(mason_name)
return Optional.of {
lspconfig_name = lspconfig_name,
mason_name = mason_name,
lspconfig_url = lspconfig_url,
lspconfig_url = get_lspconfig_url(lspconfig_name),
mason_url = mason_url,
}
end),
Expand Down Expand Up @@ -128,10 +129,107 @@ local function create_server_mapping_docs()
end
end

local find_index = _.curryN(function(predicate, list)
for i, item in ipairs(list) do
if predicate(item) then
return i
end
end
return -1
end, 2)

---@async
local function update_available_lsp_servers()
local readme_path = "README.md"
local readme_contents = fs.sync.read_file(readme_path)
local readme_lines = _.split("\n", readme_contents)

local start = find_index(_.equals "<!-- available-lsp-servers:start -->", readme_lines) + 1
local stop = find_index(_.equals "<!-- available-lsp-servers:end -->", readme_lines) - 1

for i = stop, start, -1 do
table.remove(readme_lines, i)
end

local server_mappings = require("mason-lspconfig.mappings.server").lspconfig_to_package
local registry = require "mason-registry"

---@type {languages: string[], name: string}[]
local servers = {}

for lspconfig_name, mason_name in pairs(server_mappings) do
local pkg = registry.get_package(mason_name)
table.insert(servers, {
languages = pkg.spec.languages,
name = lspconfig_name,
})
end

local servers_markdown_list = _.compose(
_.map(function(entry)
local server_docs = path.concat { MASON_LSPCONFIG_DIR, "server_configurations", entry.server, "README.md" }
if fs.sync.file_exists(server_docs) then
return ("| %s ([docs](%s)) | [`%s`](%s) |"):format(
entry.language,
server_docs,
entry.server,
get_lspconfig_url(entry.server)
)
else
return ("| %s | [`%s`](%s) |"):format(entry.language, entry.server, get_lspconfig_url(entry.server))
end
end),
_.sort_by(function(entry)
if entry.language == "-" then
-- brother eww
return "zzzz" .. (entry.language .. entry.server):lower()
else
return (entry.language .. entry.server):lower()
end
end),
function(tbl)
return vim.iter(tbl):flatten():totable()
end,
_.map(function(server)
if #server.languages == 0 then
return {
{
server = server.name,
language = "-",
},
}
else
return _.map(function(language)
return {
server = server.name,
language = language,
}
end, server.languages)
end
end)
)(servers)

for i = #servers_markdown_list, 1, -1 do
table.insert(readme_lines, start, servers_markdown_list[i])
end

for _, line in
ipairs(_.reverse {
"| Language | Server name |",
"| --- | --- |",
})
do
table.insert(readme_lines, start, line)
end

fs.sync.write_file(readme_path, _.join("\n", readme_lines))
end

a.run_blocking(function()
a.wait_all {
create_lspconfig_filetype_map,
ensure_valid_package_name_translations,
create_server_mapping_docs,
update_available_lsp_servers,
}
end)

0 comments on commit 3ce7e05

Please sign in to comment.