Compare commits

..

13 Commits

Author SHA1 Message Date
THEON-1
288621e1a4 Lazy update 2025-12-23 12:58:59 +01:00
THEON-1
5123a6cc03 some plugin changes 2025-12-23 12:58:50 +01:00
THEON-1
ae30620d2a added <C-a> and <C-e> support 2025-12-23 12:58:34 +01:00
THEON-1
1d941bca87 Lazy update 2025-12-21 14:44:25 +01:00
THEON-1
f999ff81f9 Lazy update 2025-12-20 19:55:41 +01:00
THEON-1
06ba2f478d Lazy update 2025-12-08 13:37:37 +01:00
THEON-1
e5ebca8094 Lazy update 2025-12-08 11:45:56 +01:00
THEON-1
0e3a2dd8cc new ftkeybinds scheme working for arduino 2025-12-03 18:23:38 +01:00
THEON-1
92961e4b42 arduino lsp fix 2025-12-03 18:23:09 +01:00
THEON-1
97864420c3 switched from Mason + mason-lspconfig to custom install 2025-12-03 17:13:52 +01:00
THEON-1
b31dab0c4f Lazy update 2025-12-03 10:35:37 +01:00
THEON-1
608d71b7b1 Lazy update 2025-11-29 00:09:35 +01:00
THEON-1
ecd31ab3fe trim lsp logfile on startup 2025-11-28 16:33:43 +01:00
17 changed files with 351 additions and 70 deletions

View File

@@ -1,20 +1,19 @@
{
"blink.cmp": { "branch": "main", "commit": "b19413d214068f316c78978b08264ed1c41830ec" },
"fzf-lua": { "branch": "main", "commit": "9a0704e8af8f8442110ff22a83b5608366b235df" },
"fzf-lua": { "branch": "main", "commit": "b1d2b0dc146cb9260209da4d7ab754adb0a2653d" },
"gruvbox.nvim": { "branch": "main", "commit": "5e0a460d8e0f7f669c158dedd5f9ae2bcac31437" },
"image.nvim": { "branch": "master", "commit": "446a8a5cc7a3eae3185ee0c697732c32a5547a0b" },
"lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "7d527c76c43f46294de9c19d39c5a86317809b4b" },
"mason.nvim": { "branch": "main", "commit": "57e5a8addb8c71fb063ee4acda466c7cf6ad2800" },
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "0b9bb925c000ae649ff7e7149c8cd00031f4b539" },
"mini.icons": { "branch": "main", "commit": "ff2e4f1d29f659cc2bad0f9256f2f6195c6b2428" },
"molten-nvim": { "branch": "main", "commit": "a286aa914d9a154bc359131aab788b5a077a5a99" },
"noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" },
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
"nvim-lspconfig": { "branch": "master", "commit": "de659c9c0d53df0e6b4747d8d1ef22ba1164291d" },
"nvim-lspconfig": { "branch": "master", "commit": "effe4bf2e1afb881ea67291c648b68dd3dfc927a" },
"nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" },
"nvim-treesitter": { "branch": "main", "commit": "d56ed0f7f90d6492ce422f5e0a9cb36d3169eb96" },
"oil.nvim": { "branch": "master", "commit": "01cb3a8ad7d5e8707041edc775af83dbf33838f4" },
"render-markdown.nvim": { "branch": "main", "commit": "6e0e8902dac70fecbdd8ce557d142062a621ec38" },
"nvim-treesitter": { "branch": "main", "commit": "6e42d823ce0a5a76180c473c119c7677738a09d1" },
"oil.nvim": { "branch": "master", "commit": "756dec855b4811f2d27f067a3aca477f368d99f5" },
"render-markdown.nvim": { "branch": "main", "commit": "b2b135347e299ffbf7f4123fb7811899b0c9f4b8" },
"undotree": { "branch": "master", "commit": "0f1c9816975b5d7f87d5003a19c53c6fd2ff6f7f" },
"vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" }
}

View File

@@ -1,8 +1,13 @@
local function markdown(options)
local function options2list(options)
local options_list = {}
for opt in options:gmatch("%S+") do
table.insert(options_list, opt)
end
return options_list
end
local function markdown(options)
local options_list = options2list(options or "")
local cmd = vim.list_extend(
{ "pandoc" },
options_list
@@ -25,49 +30,71 @@ local function markdown(options)
end
local function arduino(options)
local arduino_process = vim.system({
"arduino-cli",
"board",
"listall",
"--json"
})
local boards_json = arduino_process:wait()
local jq_process = vim.system({
"jq",
"[.boards.[] | {(.name): .fqbn}] | add",
}, { stdin = boards_json.stdout })
local boards_jq = jq_process:wait().stdout or {}
local boards_table = vim.json.decode(boards_jq)
local function table_keys(t)
local keys = {}
for k in pairs(t) do keys[#keys + 1] = k end
return keys
local options_list = options2list(options or "")
local options_string = ""
for _, opt in pairs(options_list) do
options_string = options_string .. " -D" .. opt
end
local keys = table_keys(boards_table)
table.sort(keys)
require("fzf-lua").fzf_exec(keys, {
actions = {
['default'] = function(selected, opts)
local process = vim.system({
"arduino-cli",
"compile",
"--fqbn",
boards_table[selected[1]],
"-e",
"--build-property",
"compiler.cpp.extra_flags=" .. options_string,
vim.fn.expand("%:p:h")
})
local result = process:wait()
vim.notify(result.stdout, vim.log.levels.INFO)
vim.notify(result.stderr, vim.log.levels.ERROR)
end,
}
})
end
local function tex(options)
--local function arduino2()
-- local arduino_process = vim.system({
-- "arduino-cli",
-- "board",
-- "listall",
-- "--json"
-- })
-- local boards_json = arduino_process:wait()
--
-- local jq_process = vim.system({
-- "jq",
-- "[.boards.[] | {(.name): .fqbn}] | add",
-- }, { stdin = boards_json.stdout })
-- local boards_jq = jq_process:wait().stdout or {}
-- local boards_table = vim.json.decode(boards_jq)
--
-- local function table_keys(t)
-- local keys = {}
-- for k in pairs(t) do keys[#keys + 1] = k end
-- return keys
-- end
--
-- local keys = table_keys(boards_table)
-- table.sort(keys)
-- require("fzf-lua").fzf_exec(keys, {
-- actions = {
-- ['default'] = function(selected, opts)
-- local process = vim.system({
-- "arduino-cli",
-- "compile",
-- "-e",
-- "--fqbn",
-- boards_table[selected[1]],
-- vim.fn.expand("%:p:h")
-- })
-- local result = process:wait()
--
-- vim.notify(result.stdout, vim.log.levels.INFO)
-- vim.notify(result.stderr, vim.log.levels.ERROR)
-- end,
-- }
-- })
--end
local function tex()
local pdflatex_process = vim.system({
"pdflatex",
vim.fn.expand("%:p"),
@@ -78,12 +105,12 @@ local function tex(options)
vim.notify(pdflatex_result.stderr, vim.log.levels.ERROR);
end
local function run_ft_action(options)
local default = {
__index = function()
return function() end
end,
}
local fttable = {
["markdown"] = markdown,
["arduino"] = arduino,
@@ -91,12 +118,12 @@ local function run_ft_action(options)
}
setmetatable(fttable, default)
fttable[vim.bo.filetype](options)
end
local fttable2 = {
["markdown"] = function() markdown(vim.fn.input("enter additional options")) end,
["arduino"] = function() arduino(vim.fn.input("enter preprocessor defines")) end,
}
setmetatable(fttable2, fttable)
vim.keymap.set("n", "<F5>", function () run_ft_action("") end)
vim.keymap.set("n", "<F6>", function()
run_ft_action(vim.fn.input("enter additional options"))
end)
vim.keymap.set("n", "<F5>", function() fttable[vim.bo.filetype]() end)
vim.keymap.set("n", "<F6>", function() fttable2[vim.bo.filetype]() end)

View File

@@ -1,3 +1,5 @@
require("config.startup")
require("config.vars")
require("config.keybinds")
require("config.ftkeybinds")

View File

@@ -2,6 +2,13 @@
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
-- move to line start/end
vim.keymap.set('i', "<C-e>", "<C-o>$")
vim.keymap.set('i', "<C-a>", "<C-o>^")
vim.keymap.set({ 'n', 'v' }, "<C-e>", '$')
vim.keymap.set({ 'n', 'v' }, "<C-a>", '^')
-- yank to clipboard
vim.keymap.set("n", "<leader>y", "\"+y")
vim.keymap.set("v", "<leader>y", "\"+y")

12
lua/config/startup.lua Normal file
View File

@@ -0,0 +1,12 @@
local logfile = vim.lsp.log.get_filename()
local tail_process = vim.system({
"tail",
"-n 10000",
logfile,
}, {}, function(res)
vim.schedule(function ()
vim.fn.writefile(vim.split(res.stdout, "\n", { plain = true }), logfile)
end)
end)

View File

@@ -1,13 +1,30 @@
vim.lsp.config("arduino_language_server", {
---@type vim.lsp.Config
local config = {
cmd = {
"arduino-language-server",
--"--fqbn",
--"arduino:avr:micro",
},
filetypes = {
"arduino",
"cpp",
},
})
root_dir = function (bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
--vim.notify(vim.fs.find({ vim.fn.fnamemodify(fname, ':t:r') }, { type = "directory", upward = true })[1])
on_dir(vim.fs.find({ vim.fn.fnamemodify(fname, ':t:r') }, { type = "directory", upward = true })[1])
end,
capabilities = {
textDocument = {
---@diagnostic disable-next-line: assign-type-mismatch
semanticTokens = vim.NIL,
},
workspace = {
---@diagnostic disable-next-line: assign-type-mismatch
semanticTokens = vim.NIL,
},
},
}
vim.lsp.config['arduino_language_server'] = config
vim.lsp.enable('arduino_language_server')

View File

@@ -1,3 +1,6 @@
# https://github.com/neovim/nvim-lspconfig/blob/master/lsp
require("lsp.arduino")
require("lsp.latex")
require("lsp.lua")
require("lsp.python")

171
lua/lsp/latex.lua Normal file
View File

@@ -0,0 +1,171 @@
local function buf_build(client, bufnr)
local win = vim.api.nvim_get_current_win()
local params = vim.lsp.util.make_position_params(win, client.offset_encoding)
client:request('textDocument/build', params, function(err, result)
if err then
error(tostring(err))
end
local texlab_build_status = {
[0] = 'Success',
[1] = 'Error',
[2] = 'Failure',
[3] = 'Cancelled',
}
vim.notify('Build ' .. texlab_build_status[result.status], vim.log.levels.INFO)
end, bufnr)
end
local function buf_search(client, bufnr)
local win = vim.api.nvim_get_current_win()
local params = vim.lsp.util.make_position_params(win, client.offset_encoding)
client:request('textDocument/forwardSearch', params, function(err, result)
if err then
error(tostring(err))
end
local texlab_forward_status = {
[0] = 'Success',
[1] = 'Error',
[2] = 'Failure',
[3] = 'Unconfigured',
}
vim.notify('Search ' .. texlab_forward_status[result.status], vim.log.levels.INFO)
end, bufnr)
end
local function buf_cancel_build(client, bufnr)
return client:exec_cmd({
title = 'cancel',
command = 'texlab.cancelBuild',
}, { bufnr = bufnr })
end
local function dependency_graph(client)
client:exec_cmd({ command = 'texlab.showDependencyGraph' }, { bufnr = 0 }, function(err, result)
if err then
return vim.notify(err.code .. ': ' .. err.message, vim.log.levels.ERROR)
end
vim.notify('The dependency graph has been generated:\n' .. result, vim.log.levels.INFO)
end)
end
local function command_factory(cmd)
local cmd_tbl = {
Auxiliary = 'texlab.cleanAuxiliary',
Artifacts = 'texlab.cleanArtifacts',
}
return function(client, bufnr)
return client:exec_cmd({
title = ('clean_%s'):format(cmd),
command = cmd_tbl[cmd],
arguments = { { uri = vim.uri_from_bufnr(bufnr) } },
}, { bufnr = bufnr }, function(err, _)
if err then
vim.notify(('Failed to clean %s files: %s'):format(cmd, err.message), vim.log.levels.ERROR)
else
vim.notify(('Command %s executed successfully'):format(cmd), vim.log.levels.INFO)
end
end)
end
end
local function buf_find_envs(client, bufnr)
local win = vim.api.nvim_get_current_win()
client:exec_cmd({
command = 'texlab.findEnvironments',
arguments = { vim.lsp.util.make_position_params(win, client.offset_encoding) },
}, { bufnr = bufnr }, function(err, result)
if err then
return vim.notify(err.code .. ': ' .. err.message, vim.log.levels.ERROR)
end
local env_names = {}
local max_length = 1
for _, env in ipairs(result) do
table.insert(env_names, env.name.text)
max_length = math.max(max_length, string.len(env.name.text))
end
for i, name in ipairs(env_names) do
env_names[i] = string.rep(' ', i - 1) .. name
end
vim.lsp.util.open_floating_preview(env_names, '', {
height = #env_names,
width = math.max((max_length + #env_names - 1), (string.len 'Environments')),
focusable = false,
focus = false,
title = 'Environments',
})
end)
end
local function buf_change_env(client, bufnr)
vim.ui.input({ prompt = 'New environment name: ' }, function(input)
if not input or input == '' then
return vim.notify('No environment name provided', vim.log.levels.WARN)
end
local pos = vim.api.nvim_win_get_cursor(0)
return client:exec_cmd({
title = 'change_environment',
command = 'texlab.changeEnvironment',
arguments = {
{
textDocument = { uri = vim.uri_from_bufnr(bufnr) },
position = { line = pos[1] - 1, character = pos[2] },
newName = tostring(input),
},
},
}, { bufnr = bufnr })
end)
end
---@type vim.lsp.Config
local config = {
cmd = { 'texlab' },
filetypes = { 'tex', 'plaintex', 'bib' },
root_markers = { '.git', '.latexmkrc', 'latexmkrc', '.texlabroot', 'texlabroot', 'Tectonic.toml' },
settings = {
texlab = {
rootDirectory = nil,
build = {
executable = 'latexmk',
args = { '-pdf', '-interaction=nonstopmode', '-synctex=1', '%f' },
onSave = false,
forwardSearchAfter = false,
},
forwardSearch = {
executable = nil,
args = {},
},
chktex = {
onOpenAndSave = false,
onEdit = false,
},
diagnosticsDelay = 300,
latexFormatter = 'latexindent',
latexindent = {
['local'] = nil, -- local is a reserved keyword
modifyLineBreaks = false,
},
bibtexFormatter = 'texlab',
formatterLineLength = 80,
},
},
on_attach = function(client, bufnr)
for _, cmd in ipairs({
{ name = 'TexlabBuild', fn = buf_build, desc = 'Build the current buffer' },
{ name = 'TexlabForward', fn = buf_search, desc = 'Forward search from current position' },
{ name = 'TexlabCancelBuild', fn = buf_cancel_build, desc = 'Cancel the current build' },
{ name = 'TexlabDependencyGraph', fn = dependency_graph, desc = 'Show the dependency graph' },
{ name = 'TexlabCleanArtifacts', fn = command_factory('Artifacts'), desc = 'Clean the artifacts' },
{ name = 'TexlabCleanAuxiliary', fn = command_factory('Auxiliary'), desc = 'Clean the auxiliary files' },
{ name = 'TexlabFindEnvironments', fn = buf_find_envs, desc = 'Find the environments at current position' },
{ name = 'TexlabChangeEnvironment', fn = buf_change_env, desc = 'Change the environment at current position' },
}) do
vim.api.nvim_buf_create_user_command(bufnr, 'Lsp' .. cmd.name, function()
cmd.fn(client, bufnr)
end, { desc = cmd.desc })
end
end,
}
vim.lsp.config['texlab'] = config
vim.lsp.enable('texlab')

17
lua/lsp/lua.lua Normal file
View File

@@ -0,0 +1,17 @@
---@type vim.lsp.Config
local config = {
cmd = { 'lua-language-server' },
filetypes = { 'lua' },
root_markers = { { '.luarc.json', '.luarc.jsonc' }, '.git' },
settings = {
codeLens = { enable = true },
hine = {
enable = true,
semicolon = 'Disable',
},
},
}
vim.lsp.config['lua_ls'] = config
vim.lsp.enable('lua_ls')

18
lua/lsp/python.lua Normal file
View File

@@ -0,0 +1,18 @@
---@type vim.lsp.Config
local config = {
cmd = { 'pylsp' },
filetypes = { 'python' },
root_markers = {
'pyproject.toml',
'setup.py',
'setup.cfg',
'requirements.txt',
'Pipfile',
'.git',
},
}
vim.lsp.config['python-language-server'] = config
vim.lsp.enable('python-language-server')

View File

@@ -12,5 +12,6 @@ return {
window_overlap_clear_enabled = true,
window_overlap_clear_ft_ignore = { 'cmp_menu', 'cmp_docs', '', },
},
lazy = true,
}

View File

@@ -25,5 +25,6 @@ return {
'latex2text',
},
},
enabled = false,
}

View File

@@ -19,5 +19,6 @@ return {
},
"neovim/nvim-lspconfig",
},
enabled = false,
}

View File

@@ -1,4 +1,5 @@
return {
'nvim-mini/mini.icons',
lazy = true,
}

View File

@@ -7,5 +7,6 @@ return {
vim.g.molten_image_provider = 'image.nvim'
vim.g.molten_output_win_max_height = 20
end,
enabled = false,
}

View File

@@ -3,5 +3,6 @@ return {
cmd = { 'LspInfo', 'LspInstall', 'LspStart' },
event = { 'BufReadPre', 'BufNewFile' },
dependencies = { 'saghen/blink.cmp' },
enabled = false,
}

View File

@@ -1,5 +1,7 @@
return {
'stevearc/oil.nvim',
--dependencies = { "nvim-mini/mini.icons" },
---@module 'oil'
---@type oil.SetupOpts
opts = {