aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2025-01-21 14:35:04 +0100
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2025-01-21 15:45:44 +0100
commitd9fbdafd80350b38c15521e11e66936032ed90d1 (patch)
treed9eda9584e81d9e853349032b571892d6ab89010 /scripts
parentci: use the head ref when checking out (diff)
downloadnvim-lspconfig-d9fbdafd80350b38c15521e11e66936032ed90d1.tar
nvim-lspconfig-d9fbdafd80350b38c15521e11e66936032ed90d1.tar.gz
nvim-lspconfig-d9fbdafd80350b38c15521e11e66936032ed90d1.tar.bz2
nvim-lspconfig-d9fbdafd80350b38c15521e11e66936032ed90d1.tar.lz
nvim-lspconfig-d9fbdafd80350b38c15521e11e66936032ed90d1.tar.xz
nvim-lspconfig-d9fbdafd80350b38c15521e11e66936032ed90d1.tar.zst
nvim-lspconfig-d9fbdafd80350b38c15521e11e66936032ed90d1.zip
build: remove `docgen.sh`
Instead, generate documentation by running the `docgen.lua` executable.
Diffstat (limited to 'scripts')
-rwxr-xr-x[-rw-r--r--]scripts/docgen.lua22
-rwxr-xr-xscripts/docgen.sh2
2 files changed, 15 insertions, 9 deletions
diff --git a/scripts/docgen.lua b/scripts/docgen.lua
index c1302bb5..538ed2ad 100644..100755
--- a/scripts/docgen.lua
+++ b/scripts/docgen.lua
@@ -1,3 +1,7 @@
+#!/usr/bin/env -S nvim -l
+local root = vim.trim(vim.system({ 'git', 'rev-parse', '--show-toplevel' }):wait().stdout)
+vim.opt.rtp:append(root)
+
require 'lspconfig'
local configs = require 'lspconfig.configs'
local util = require 'lspconfig.util'
@@ -89,7 +93,7 @@ local function require_all_configs()
vim.env.XDG_CACHE_HOME = '/home/user/.cache'
-- Configs are lazy-loaded, tickle them to populate the `configs` singleton.
- for _, v in ipairs(vim.fn.glob('lua/lspconfig/configs/*.lua', true, true)) do
+ for _, v in ipairs(vim.fn.glob(vim.fs.joinpath(root, 'lua/lspconfig/configs/*.lua'), true, true)) do
local module_name = v:gsub('.*/', ''):gsub('%.lua$', '')
configs[module_name] = require('lspconfig.configs.' .. module_name)
end
@@ -107,7 +111,7 @@ local function make_lsp_sections()
local template_def = template_object.config_def
local docs = template_def.docs
-- "lua/lspconfig/configs/xx.lua"
- local config_file = ('lua/lspconfig/configs/%s.lua'):format(config_name)
+ local config_file = (vim.fs.joinpath(root, 'lua/lspconfig/configs/%s.lua')):format(config_name)
local params = {
config_name = config_name,
@@ -155,13 +159,14 @@ local function make_lsp_sections()
end
end
io.close(file)
+ local config_relpath = vim.fs.relpath(root, config_file)
-- XXX: "../" because the path is outside of the doc/ dir.
return ('- `%s` source (use "gF" to visit): [../%s:%d](../%s#L%d)'):format(
k,
- config_file,
+ config_relpath,
linenr,
- config_file,
+ config_relpath,
linenr
)
end),
@@ -284,14 +289,17 @@ local function generate_readme(template_file, params)
local input_template = readfile(template_file)
local readme_data = template(input_template, params)
- local writer = assert(io.open('doc/configs.md', 'w'))
+ local conf_md = vim.fs.joinpath(root, 'doc/configs.md')
+ local conf_txt = vim.fs.joinpath(root, 'doc/configs.txt')
+
+ local writer = assert(io.open(conf_md, 'w'))
writer:write(readme_data)
writer:close()
- vim.loop.fs_copyfile('doc/configs.md', 'doc/configs.txt')
+ vim.loop.fs_copyfile(conf_md, conf_txt)
end
require_all_configs()
-generate_readme('scripts/docs_template.md', {
+generate_readme(vim.fs.joinpath(root, 'scripts/docs_template.md'), {
implemented_servers_list = make_implemented_servers_list(),
lsp_server_details = make_lsp_sections(),
})
diff --git a/scripts/docgen.sh b/scripts/docgen.sh
deleted file mode 100755
index 28846543..00000000
--- a/scripts/docgen.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-exec nvim -u NONE -E -R --headless +'set rtp+=$PWD' +'luafile scripts/docgen.lua' +q