fix: Cleaning up some aspects of the language support work to move into

development and finish cleaning the main branch.
This commit is contained in:
2026-08-12 09:46:56 -05:00
parent 48235c005d
commit 6e035d1f4c
10 changed files with 139 additions and 53 deletions

View File

@@ -1,9 +0,0 @@
return {
cmd = {
"arduino-language-server",
"-clangd", "/usr/lib/llvm/21/bin/clangd",
"-cli", "/usr/bin/arduino-cli",
"-cli-config", "~/.arduino15/arduino-cli.yaml",
"-fqbn", "esp32:esp32:adafruit_qtpy_esp32s3_nopsram"
}
}

View File

@@ -1,3 +1,10 @@
return {
filetypes = { 'zsh', 'bash', 'sh' }
cmd = { 'bash-language-server', 'start' },
settings = {
bashIde = {
globPattern = vim.env.GLOB_PATTERN or '*@(.sh|.inc|.bash|.command)',
},
},
filetypes = { 'zsh', 'bash', 'sh' },
root_markers = { '.git' },
}

91
nvim/after/lsp/clangd.lua Normal file
View File

@@ -0,0 +1,91 @@
-- https://clangd.llvm.org/extensions.html#switch-between-sourceheader
local function switch_source_header(bufnr, client)
local method_name = 'textDocument/switchSourceHeader'
---@diagnostic disable-next-line:param-type-mismatch
if not client or not client:supports_method(method_name) then
return vim.notify(('method %s is not supported by any servers active on the current buffer'):format(method_name))
end
local params = vim.lsp.util.make_text_document_params(bufnr)
---@diagnostic disable-next-line:param-type-mismatch
client:request(method_name, params, function(err, result)
if err then
error(tostring(err))
end
if not result then
vim.notify('corresponding file cannot be determined')
return
end
vim.cmd.edit(vim.uri_to_fname(result))
end, bufnr)
end
local function symbol_info(bufnr, client)
local method_name = 'textDocument/symbolInfo'
---@diagnostic disable-next-line:param-type-mismatch
if not client or not client:supports_method(method_name) then
return vim.notify('Clangd client not found', vim.log.levels.ERROR)
end
local win = vim.api.nvim_get_current_win()
local params = vim.lsp.util.make_position_params(win, client.offset_encoding)
---@diagnostic disable-next-line:param-type-mismatch
client:request(method_name, params, function(err, res)
if err or #res == 0 then
-- Clangd always returns an error, there is no reason to parse it
return
end
local container = string.format('container: %s', res[1].containerName) ---@type string
local name = string.format('name: %s', res[1].name) ---@type string
vim.lsp.util.open_floating_preview({ name, container }, '', {
height = 2,
width = math.max(string.len(name), string.len(container)),
focusable = false,
focus = false,
title = 'Symbol Info',
})
end, bufnr)
end
---@class ClangdInitializeResult: lsp.InitializeResult
---@field offsetEncoding? string
---@type vim.lsp.Config
return {
cmd = { 'clangd' },
filetypes = { 'c', 'c.doxygen', 'cpp', 'cpp.doxygen', 'objc', 'objcpp', 'cuda' },
root_markers = {
'.clangd',
'.clang-tidy',
'.clang-format',
'compile_commands.json',
'compile_flags.txt',
'configure.ac', -- AutoTools
'.git',
},
get_language_id = function(_, ftype)
local t = { objc = 'objective-c', objcpp = 'objective-cpp', cuda = 'cuda-cpp' }
return t[ftype] or ftype
end,
capabilities = {
textDocument = {
completion = {
editsNearCursor = true,
},
},
offsetEncoding = { 'utf-8', 'utf-16' },
},
---@param init_result ClangdInitializeResult
on_init = function(client, init_result)
if init_result.offsetEncoding then
client.offset_encoding = init_result.offsetEncoding
end
end,
on_attach = function(client, bufnr)
vim.api.nvim_buf_create_user_command(bufnr, 'LspClangdSwitchSourceHeader', function()
switch_source_header(bufnr, client)
end, { desc = 'Switch between source/header' })
vim.api.nvim_buf_create_user_command(bufnr, 'LspClangdShowSymbolInfo', function()
symbol_info(bufnr, client)
end, { desc = 'Show symbol info' })
end,
}

View File

@@ -1,7 +1,7 @@
return {
cmd = vim.lsp.rpc.connect('127.0.0.1', 6005),
filetypes = {
'gd', 'gdscript', 'gdscript3'
},
root_markers = { 'project.godot', '.git' },
cmd = vim.lsp.rpc.connect('127.0.0.1', 6005)
}

View File

@@ -1,3 +0,0 @@
return {
template_extension = { 'html', 'jinja', 'j2', 'tera' }
}

View File

@@ -0,0 +1,15 @@
vim.filetype.add {
extension = {
-- tera = 'jinja',
jinja = 'jinja',
jinja2 = 'jinja',
j2 = 'jinja',
}
}
return {
name = 'jinja_lsp',
cmd = { 'jinja-lsp' },
filetypes = { 'jinja', 'tera', 'html' },
-- template_extension = { 'html', 'jinja', 'j2', 'tera' },
}

View File

@@ -1,4 +1,14 @@
return {
cmd = { 'pylsp' },
filetypes = { 'python' },
root_markers = {
'pyproject.toml',
'setup.py',
'setup.cfg',
'requirements.txt',
'Pipfile',
'.git',
},
settings = {
pylsp = {
plugins = {

View File

@@ -28,5 +28,4 @@ vim.schedule(function()
-- Experimental
-- require('plugins.note_taking') -- In house note taking plugin (TODO: rename once the plugin name is solidified)
-- require('plugins.nvim-lint') -- Linter loader
end)

View File

@@ -9,7 +9,6 @@ end
-- Start treesitter parsing on the current buffer
vim.api.nvim_create_autocmd("FileType", {
callback = function(ev)
-- Use pcall to prevent blocking errors
pcall(vim.treesitter.start, ev.buf)
end
})
@@ -53,10 +52,9 @@ vim.api.nvim_create_autocmd('LspAttach', {
-- end,
-- })
-- Keyboard Mappings
local bufnr = args.buf
local bufopts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set('n', '<C-[>', function() vim.diagnostic.jump({ count = -1, float = true }) end, bufopts)
vim.keymap.set('n', '<C-]>', function() vim.diagnostic.jump({ count = 1, float = true }) end, bufopts)
vim.keymap.set('n', 'ga', vim.lsp.buf.code_action, bufopts)
@@ -74,6 +72,14 @@ vim.api.nvim_create_autocmd('LspAttach', {
})
-- Enable LSP engines
-- vim.lsp.enable('clangd')
vim.lsp.enable('gdscript')
vim.lsp.enable('r_language_server')
local enabled_lsps = {
'clangd',
'gdscript',
'jinja_lsp',
'pylsp',
'r_language_server',
}
for _, lsp in pairs(enabled_lsps) do
vim.lsp.enable(lsp)
end

View File

@@ -24,36 +24,6 @@ config.automatically_reload_config = true
-- Linux specific fixes
if wezterm.target_triple == 'x86_64-unknown-linux-gnu' then
-- Fixing the cursor theme
-- local xcursor_size = nil
-- local xcursor_theme = nil
--
-- local theme_success, stdout, _ = wezterm.run_child_process({
-- "gsettings",
-- "get",
-- "org.gnome.desktop.interface",
-- "cursor-theme"
-- })
--
-- if theme_success then
-- xcursor_theme = stdout:gsub("'(.+)'\n", "%1")
-- end
--
-- local cursor_success, _, _ = wezterm.run_child_process({
-- "gsettings",
-- "get",
-- "org.gnome.desktop.interface",
-- "cursor-size"
-- })
--
-- if cursor_success then
-- xcursor_size = tonumber(stdout)
-- end
--
-- config.xcursor_theme = xcursor_theme
-- config.xcursor_size = xcursor_size
-- end cursor theme
config.disable_default_key_bindings = true
end