shrug, i forgor

This commit is contained in:
gyoder 2025-12-28 15:38:19 -07:00
parent 428c884e0d
commit a01bb5c0ed
19 changed files with 538 additions and 68 deletions

View file

@ -0,0 +1,66 @@
---@brief
---
--- https://detachhead.github.io/basedpyright
---
--- `basedpyright`, a static type checker and language server for python
local function set_python_path(command)
local path = command.args
local clients = vim.lsp.get_clients {
bufnr = vim.api.nvim_get_current_buf(),
name = 'basedpyright',
}
for _, client in ipairs(clients) do
if client.settings then
client.settings.python = vim.tbl_deep_extend('force', client.settings.python or {}, { pythonPath = path })
else
client.config.settings = vim.tbl_deep_extend('force', client.config.settings, { python = { pythonPath = path } })
end
client:notify('workspace/didChangeConfiguration', { settings = nil })
end
end
---@type vim.lsp.Config
return {
cmd = { 'basedpyright-langserver', '--stdio' },
filetypes = { 'python' },
root_markers = {
'pyproject.toml',
'setup.py',
'setup.cfg',
'requirements.txt',
'Pipfile',
'pyrightconfig.json',
'.git',
},
settings = {
basedpyright = {
analysis = {
autoSearchPaths = true,
useLibraryCodeForTypes = true,
diagnosticMode = 'openFilesOnly',
},
},
},
on_attach = function(client, bufnr)
vim.api.nvim_buf_create_user_command(bufnr, 'LspPyrightOrganizeImports', function()
local params = {
command = 'basedpyright.organizeimports',
arguments = { vim.uri_from_bufnr(bufnr) },
}
-- Using client.request() directly because "basedpyright.organizeimports" is private
-- (not advertised via capabilities), which client:exec_cmd() refuses to call.
-- https://github.com/neovim/neovim/blob/c333d64663d3b6e0dd9aa440e433d346af4a3d81/runtime/lua/vim/lsp/client.lua#L1024-L1030
client.request('workspace/executeCommand', params, nil, bufnr)
end, {
desc = 'Organize Imports',
})
vim.api.nvim_buf_create_user_command(bufnr, 'LspPyrightSetPythonPath', set_python_path, {
desc = 'Reconfigure basedpyright with the provided python path',
nargs = 1,
complete = 'file',
})
end,
}

View file

@ -4,7 +4,11 @@ return {
-- '--clang-tidy',
'--background-index',
'--offset-encoding=utf-8',
'--query-driver=/Users/scie/.platformio/packages/toolchain-xtensa-esp32/**'
'--query-driver=/Users/scie/.platformio/packages/toolchain-xtensa-esp32/**',
'--query-driver=/Users/scie/.platformio/packages/framework-arduinoststm32/**',
-- '--query-driver=/Users/scie/.platformio/packages/**',
-- '--query-driver=/opt/homebrew/Cellar/avr-gcc@9/9.4.0_1/bin/avr-gcc',
-- '--query-driver=/opt/homebrew/Cellar/avr-gcc@9/9.4.0_1/bin/avr-g++'
},
filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda', 'proto', 'arduino' },
root_markers = {
@ -25,4 +29,3 @@ return {
offsetEncoding = { 'utf-8', 'utf-16' },
},
}

View file

@ -0,0 +1,9 @@
---@type vim.lsp.Config
return {
cmd = { 'csharp-ls' },
root_markers = { ".git" },
filetypes = { 'cs' },
init_options = {
AutomaticWorkspaceInit = true,
},
}

View file

@ -4,7 +4,7 @@
---
return {
cmd = { 'cspell-lsp', '--stdio' },
filetypes = {"go", "rust", "js", "ts", "html", "css", "json", "yaml", "markdown", "gitcommit", "typst", "lua", "htmlua"},
filetypes = { "go", "rust", "js", "ts", "html", "css", "json", "yaml", "markdown", "gitcommit", "typst", "lua", "htmlua", "c", "cpp", "arduino" },
root_markers = {
'.git',
'cspell.json',
@ -20,4 +20,10 @@ return {
'cspell.yaml',
'cspell.yml',
},
init_options = {
userWordsFile = vim.fn.expand('~/.config/cspell/user-dictionary.txt'),
configPaths = {
vim.fn.expand('~/.cspell.json'),
},
},
}

View file

@ -0,0 +1,9 @@
local port = os.getenv 'GDScript_Port' or '6005'
local cmd = vim.lsp.rpc.connect('127.0.0.1', tonumber(port))
---@type vim.lsp.Config
return {
cmd = cmd,
filetypes = { 'gd', 'gdscript', 'gdscript3' },
root_markers = { 'project.godot', '.git' },
}

View file

@ -0,0 +1,65 @@
---@brief
---
--- https://github.com/microsoft/pyright
---
--- `pyright`, a static type checker and language server for python
local function set_python_path(command)
local path = command.args
local clients = vim.lsp.get_clients {
bufnr = vim.api.nvim_get_current_buf(),
name = 'pyright',
}
for _, client in ipairs(clients) do
if client.settings then
client.settings.python = vim.tbl_deep_extend('force', client.settings.python, { pythonPath = path })
else
client.config.settings = vim.tbl_deep_extend('force', client.config.settings, { python = { pythonPath = path } })
end
client:notify('workspace/didChangeConfiguration', { settings = nil })
end
end
---@type vim.lsp.Config
return {
cmd = { 'pyright-langserver', '--stdio' },
filetypes = { 'python' },
root_markers = {
'pyproject.toml',
'setup.py',
'setup.cfg',
'requirements.txt',
'Pipfile',
'pyrightconfig.json',
'.git',
},
settings = {
python = {
analysis = {
autoSearchPaths = true,
useLibraryCodeForTypes = true,
diagnosticMode = 'openFilesOnly',
},
},
},
on_attach = function(client, bufnr)
vim.api.nvim_buf_create_user_command(bufnr, 'LspPyrightOrganizeImports', function()
local params = {
command = 'pyright.organizeimports',
arguments = { vim.uri_from_bufnr(bufnr) },
}
-- Using client.request() directly because "pyright.organizeimports" is private
-- (not advertised via capabilities), which client:exec_cmd() refuses to call.
-- https://github.com/neovim/neovim/blob/c333d64663d3b6e0dd9aa440e433d346af4a3d81/runtime/lua/vim/lsp/client.lua#L1024-L1030
client.request('workspace/executeCommand', params, nil, bufnr)
end, {
desc = 'Organize Imports',
})
vim.api.nvim_buf_create_user_command(bufnr, 'LspPyrightSetPythonPath', set_python_path, {
desc = 'Reconfigure pyright with the provided python path',
nargs = 1,
complete = 'file',
})
end,
}

View file

@ -0,0 +1,15 @@
return {
cmd = { "rust-analyzer" },
filetypes = { "rust", "rs" },
root_markers = { "Cargo.lock" },
settings = {
["rust-analyzer"] = {
check = {
command = "clippy",
},
diagnostics = {
enable = true,
},
},
},
}

View file

@ -1,9 +0,0 @@
return {
cmd = { 'rust-analyzer' },
filetypes = { 'rust', 'rs' },
root_markers = {
'cargo.toml',
'.git'
},
}

View file

@ -0,0 +1,77 @@
---@brief
---
--- https://github.com/Myriad-Dreamin/tinymist
--- An integrated language service for Typst [taɪpst]. You can also call it "微霭" [wēi ǎi] in Chinese.
---
--- Currently some of Tinymist's workspace commands are supported, namely:
--- `LspTinymistExportSvg`, `LspTinymistExportPng`, `LspTinymistExportPdf
--- `LspTinymistExportMarkdown`, `LspTinymistExportText`, `LspTinymistExportQuery`,
--- `LspTinymistExportAnsiHighlight`, `LspTinymistGetServerInfo`,
--- `LspTinymistGetDocumentTrace`, `LspTinymistGetWorkspaceLabels`, and
--- `LspTinymistGetDocumentMetrics`.
---@param command_name string
---@param client vim.lsp.Client
---@param bufnr integer
---@return fun():nil run_tinymist_command, string cmd_name, string cmd_desc
local function create_tinymist_command(command_name, client, bufnr)
local export_type = command_name:match 'tinymist%.export(%w+)'
local info_type = command_name:match 'tinymist%.(%w+)'
if info_type and info_type:match '^get' then
info_type = info_type:gsub('^get', 'Get')
end
local cmd_display = export_type or info_type
---@return nil
local function run_tinymist_command()
local arguments = { vim.api.nvim_buf_get_name(bufnr) }
local title_str = export_type and ('Export ' .. cmd_display) or cmd_display
---@type lsp.Handler
local function handler(err, res)
if err then
return vim.notify(err.code .. ': ' .. err.message, vim.log.levels.ERROR)
end
-- If exporting, show the string result; else, show the table for inspection
vim.notify(export_type and res or vim.inspect(res), vim.log.levels.INFO)
end
return client:exec_cmd({
title = title_str,
command = command_name,
arguments = arguments,
}, { bufnr = bufnr }, handler)
end
-- Construct a readable command name/desc
local cmd_name = export_type and ('TinymistExport' .. cmd_display) or ('Tinymist' .. cmd_display) ---@type string
local cmd_desc = export_type and ('Export to ' .. cmd_display) or ('Get ' .. cmd_display) ---@type string
return run_tinymist_command, cmd_name, cmd_desc
end
---@type vim.lsp.Config
return {
cmd = { 'tinymist' },
filetypes = { 'typst' },
root_markers = { '.git' },
on_attach = function(client, bufnr)
for _, command in ipairs {
'tinymist.exportSvg',
'tinymist.exportPng',
'tinymist.exportPdf',
-- 'tinymist.exportHtml', -- Use typst 0.13
'tinymist.exportMarkdown',
'tinymist.exportText',
'tinymist.exportQuery',
'tinymist.exportAnsiHighlight',
'tinymist.getServerInfo',
'tinymist.getDocumentTrace',
'tinymist.getWorkspaceLabels',
'tinymist.getDocumentMetrics',
} do
local cmd_func, cmd_name, cmd_desc = create_tinymist_command(command, client, bufnr)
vim.api.nvim_buf_create_user_command(bufnr, 'Lsp' .. cmd_name, cmd_func, { nargs = 0, desc = cmd_desc })
end
end,
settings = {
["tinymist"] = {
formatterMode = "typstyle"
}
}
}

View file

@ -0,0 +1,12 @@
---@brief
--- https://github.com/zigtools/zls
---
--- Zig LSP implementation + Zig Language Server
---@type vim.lsp.Config
return {
cmd = { 'zigscient' },
filetypes = { 'zig', 'zir' },
root_markers = { 'zls.json', 'build.zig', '.git' },
workspace_required = false,
}

View file

@ -1,10 +1,12 @@
---@brief
--- https://github.com/zigtools/zls
---
--- Zig LSP implementation + Zig Language Server
---@type vim.lsp.Config
return {
cmd = { 'zls' },
filetypes = { 'zig' },
root_markers = {
'zls.json',
'build.zig',
'.git'
},
filetypes = { 'zig', 'zir' },
root_markers = { 'zls.json', 'build.zig', '.git' },
workspace_required = false,
}