From 35cbeb8b1368e0b543620405d554b30dd6bebe7a Mon Sep 17 00:00:00 2001 From: dario Date: Mon, 7 Apr 2025 13:35:31 +0200 Subject: [PATCH 01/17] fix: minor misspellings --- README.md | 2 +- init.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8ace8b9b22b..c27ffedd3ce 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,7 @@ This requires: - Install CMake and the Microsoft C++ Build Tools on Windows ```lua -{'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } +{'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Build -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } ```
Windows with gcc/make using chocolatey diff --git a/init.lua b/init.lua index cbf9ff65d67..1f8d9c871a8 100644 --- a/init.lua +++ b/init.lua @@ -194,7 +194,7 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the right win vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) --- NOTE: Some terminals have coliding keymaps or are not able to send distinct keycodes +-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes -- vim.keymap.set("n", "", "H", { desc = "Move window to the left" }) -- vim.keymap.set("n", "", "L", { desc = "Move window to the right" }) -- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) From 06cd3fb3a7e4eca0711a10489870221a228c0e37 Mon Sep 17 00:00:00 2001 From: dasvh Date: Mon, 7 Apr 2025 12:11:54 +0000 Subject: [PATCH 02/17] revert change for `-Bbuild` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c27ffedd3ce..8ace8b9b22b 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,7 @@ This requires: - Install CMake and the Microsoft C++ Build Tools on Windows ```lua -{'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Build -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } +{'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } ```
Windows with gcc/make using chocolatey From 5cdacadcf87749b29e879f2196d57759b30fd364 Mon Sep 17 00:00:00 2001 From: dario Date: Mon, 7 Apr 2025 21:15:15 +0200 Subject: [PATCH 03/17] add custom configs to init.lua - tab width to 4 instead of 8 - highlight extra whitespace - trim extra whitespace on write - removed some comments --- init.lua | 62 +++++++++++++------------------------------------------- 1 file changed, 14 insertions(+), 48 deletions(-) diff --git a/init.lua b/init.lua index 1f8d9c871a8..066911259a9 100644 --- a/init.lua +++ b/init.lua @@ -1,25 +1,5 @@ --[[ -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== -======== .-----. ======== -======== .----------------------. | === | ======== -======== |.-""""""""""""""""""-.| |-----| ======== -======== || || | === | ======== -======== || KICKSTART.NVIM || |-----| ======== -======== || || | === | ======== -======== || || |-----| ======== -======== ||:Tutor || |:::::| ======== -======== |'-..................-'| |____o| ======== -======== `"")----------------(""` ___________ ======== -======== /::::::::::| |::::::::::\ \ no mouse \ ======== -======== /:::========| |==hjkl==:::\ \ required \ ======== -======== '""""""""""""' '""""""""""""' '""""""""""' ======== -======== ======== -===================================================================== -===================================================================== - What is Kickstart? Kickstart.nvim is *not* a distribution. @@ -28,10 +8,6 @@ What is Kickstart? The goal is that you can read every line of code, top-to-bottom, understand what your configuration is doing, and modify it to suit your needs. - Once you've done that, you can start exploring, configuring and tinkering to - make Neovim your own! That might mean leaving Kickstart just the way it is for a while - or immediately breaking it into modular pieces. It's up to you! - If you don't know anything about Lua, I recommend taking some time to read through a guide. One possible example which will only take 10-15 minutes: - https://learnxinyminutes.com/docs/lua/ @@ -45,17 +21,6 @@ Kickstart Guide: TODO: The very first thing you should do is to run the command `:Tutor` in Neovim. - If you don't know what this means, type the following: - - - - : - - Tutor - - - - (If you already know the Neovim basics, you can skip this step.) - - Once you've completed that, you can continue working through **AND READING** the rest - of the kickstart init.lua. - Next, run AND READ `:help`. This will open up a help window with some basic information about reading, navigating and searching the builtin help documentation. @@ -70,18 +35,6 @@ Kickstart Guide: These are hints about where to find more information about the relevant settings, plugins or Neovim features used in Kickstart. - NOTE: Look for lines like this - - Throughout the file. These are for you, the reader, to help you understand what is happening. - Feel free to delete them once you know what you're doing, but they should serve as a guide - for when you are first encountering a few different constructs in your Neovim config. - -If you experience any errors while trying to install kickstart, run `:checkhealth` for more info. - -I hope you enjoy your Neovim journey, -- TJ - -P.S. You can delete this when you're done too. It's your config now! :) --]] -- Set as the leader key @@ -161,6 +114,19 @@ vim.opt.scrolloff = 10 -- See `:help 'confirm'` vim.opt.confirm = true +-- set tabs to 4 spaces (default is 8) +vim.bo.tabstop = 4 +vim.bo.shiftwidth = 4 +vim.bo.softtabstop = 4 + +-- highlight ExtraWhitespace +-- TODO: does not seem to clear all whitespace (-> did not work for yaml file) +vim.api.nvim_set_hl(0, 'ExtraWhitespace', { + fg = nil, + bg = '#ff80ff', -- Hex color +}) +vim.cmd [[match ExtraWhitespace /\s\+$/]] + -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` @@ -670,7 +636,7 @@ require('lazy').setup({ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { -- clangd = {}, - -- gopls = {}, + gopls = {}, -- pyright = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs From a44c559d1de68b7d074841b10010a8bdf2caa0b5 Mon Sep 17 00:00:00 2001 From: dario Date: Sat, 12 Apr 2025 16:16:06 +0200 Subject: [PATCH 04/17] fix: use autocommand to set indendation for Go files when jumping to a declaration the indendation defaulted back to 8 instead of 4 but with autocommand it works when jumping between files --- init.lua | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index 066911259a9..28813d2cf82 100644 --- a/init.lua +++ b/init.lua @@ -114,11 +114,6 @@ vim.opt.scrolloff = 10 -- See `:help 'confirm'` vim.opt.confirm = true --- set tabs to 4 spaces (default is 8) -vim.bo.tabstop = 4 -vim.bo.shiftwidth = 4 -vim.bo.softtabstop = 4 - -- highlight ExtraWhitespace -- TODO: does not seem to clear all whitespace (-> did not work for yaml file) vim.api.nvim_set_hl(0, 'ExtraWhitespace', { @@ -180,6 +175,17 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +-- Set correct indendation for Go files +vim.api.nvim_create_autocmd('FileType', { + pattern = 'go', + callback = function() + vim.bo.tabstop = 4 + vim.bo.shiftwidth = 4 + vim.bo.softtabstop = 4 + vim.bo.expandtab = false + end, +}) + -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' From 285cc4c546adc90b63dc163340e5fce6276a0af3 Mon Sep 17 00:00:00 2001 From: dario Date: Sun, 13 Apr 2025 17:01:26 +0200 Subject: [PATCH 05/17] add bashls language server --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index 28813d2cf82..80f81fdfd1b 100644 --- a/init.lua +++ b/init.lua @@ -643,6 +643,7 @@ require('lazy').setup({ local servers = { -- clangd = {}, gopls = {}, + bashls = {}, -- pyright = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs From 5790bc57c6e1bf39206628209d219c3208390dae Mon Sep 17 00:00:00 2001 From: dario Date: Mon, 28 Apr 2025 14:00:35 +0200 Subject: [PATCH 06/17] wip: nvim plugin for taskfile --- init.lua | 2 +- lua/custom/plugins/init.lua | 9 +++- lua/custom/task/init.lua | 82 +++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 lua/custom/task/init.lua diff --git a/init.lua b/init.lua index 80f81fdfd1b..fa7834f687d 100644 --- a/init.lua +++ b/init.lua @@ -974,7 +974,7 @@ require('lazy').setup({ -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-๐Ÿ”Œ-plugin-spec` -- Or use telescope! diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8d7a..b2b289d4cd2 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,11 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +return { + dir = vim.fn.stdpath('config') .. '/lua/custom/task', + name = 'custom-task', + lazy = false, + config = function() + require('custom.task').setup() + end, +} \ No newline at end of file diff --git a/lua/custom/task/init.lua b/lua/custom/task/init.lua new file mode 100644 index 00000000000..69c96047407 --- /dev/null +++ b/lua/custom/task/init.lua @@ -0,0 +1,82 @@ +local Module = {} + +Module.setup = function() end + +local function centered_float_size() + local width = math.floor(vim.o.columns * 0.8) + local height = math.floor(vim.o.lines * 0.8) + local row = math.floor((vim.o.lines - height) / 2) + local col = math.floor((vim.o.columns - width) / 2) + return width, height, row, col +end + +Module.get_tasks = function() + local response = vim.fn.system 'task --list --json' + local data = vim.fn.json_decode(response) + + -- TODO: handle 'file does not exist' from task + if not data or not data.tasks then + vim.notify('No tasks found or failed to parse JSON', vim.log.levels.ERROR) + return {} + end + + return data.tasks +end + +Module.execute_task = function(task) + local width, height, row, col = centered_float_size() + + local buf = vim.api.nvim_create_buf(false, true) + vim.api.nvim_open_win(buf, true, { + relative = 'editor', + row = row, + col = col, + width = width, + height = height, + style = 'minimal', + border = 'rounded', + }) + + vim.api.nvim_set_current_buf(buf) + vim.fn.termopen('task ' .. task) + -- vim.cmd 'startinsert' +end + +Module.on_choice = function(item) + Module.execute_task(item.name) +end + +Module.open_window = function() + local tasks = Module.get_tasks() + if #tasks == 0 then + vim.notify('No tasks available', vim.log.levels.WARN) + return + end + + local formatter = function(task) + return string.format('%-20s %s', task.name, task.desc or '') + end + + vim.ui.select(tasks, { prompt = 'Task:', format_item = formatter }, Module.on_choice) +end + +local complete = function(ArgLead, _, _) + local matches = {} + for _, task in ipairs(Module.get_tasks()) do + if task.name:lower():match('^' .. ArgLead:lower()) then + table.insert(matches, task.name) + end + end + table.sort(matches) + return matches +end + +vim.api.nvim_create_user_command('Task', function(input) + if input.args ~= '' then + Module.execute_task(input.args) + else + Module.open_window() + end +end, { bang = true, desc = 'Run tasks defined in a Taskfile', nargs = '?', complete = complete }) + +return Module From c528b074ecbc68b90e1ea9cc458672682cff08ec Mon Sep 17 00:00:00 2001 From: dario Date: Mon, 28 Apr 2025 16:37:05 +0200 Subject: [PATCH 07/17] handle missing taskfile in task plugin --- lua/custom/task/init.lua | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/lua/custom/task/init.lua b/lua/custom/task/init.lua index 69c96047407..d6176f10809 100644 --- a/lua/custom/task/init.lua +++ b/lua/custom/task/init.lua @@ -12,11 +12,16 @@ end Module.get_tasks = function() local response = vim.fn.system 'task --list --json' - local data = vim.fn.json_decode(response) + local exit_code = vim.v.shell_error - -- TODO: handle 'file does not exist' from task - if not data or not data.tasks then - vim.notify('No tasks found or failed to parse JSON', vim.log.levels.ERROR) + if exit_code ~= 0 then + vim.notify('Task command failed (missing Taskfile?)', vim.log.levels.ERROR) + return {} + end + + local ok, data = pcall(vim.fn.json_decode, response) + if not ok or not data or not data.tasks then + vim.notify('Failed to parse task output.', vim.log.levels.ERROR) return {} end @@ -27,7 +32,7 @@ Module.execute_task = function(task) local width, height, row, col = centered_float_size() local buf = vim.api.nvim_create_buf(false, true) - vim.api.nvim_open_win(buf, true, { + local win = vim.api.nvim_open_win(buf, true, { relative = 'editor', row = row, col = col, @@ -38,8 +43,21 @@ Module.execute_task = function(task) }) vim.api.nvim_set_current_buf(buf) - vim.fn.termopen('task ' .. task) - -- vim.cmd 'startinsert' + vim.fn.termopen('task ' .. task, { + on_stdout = function(_, _, _) + vim.api.nvim_command 'normal! G' + end, + on_stderr = function(_, _, _) + vim.api.nvim_command 'normal! G' + end, + on_exit = function() + vim.api.nvim_command 'normal! G' + end, + }) + + vim.keymap.set('n', 'q', function() + vim.api.nvim_win_close(win, true) + end, { buffer = buf, nowait = true, silent = true }) end Module.on_choice = function(item) From 3a8d28bf5f4827542352a2fa536d6cb0c21a754d Mon Sep 17 00:00:00 2001 From: dario Date: Wed, 30 Apr 2025 21:55:52 +0200 Subject: [PATCH 08/17] refactor: task plugin and add optional config --- lua/custom/plugins/init.lua | 10 +- lua/custom/task/init.lua | 184 ++++++++++++++++++++++++++---------- 2 files changed, 140 insertions(+), 54 deletions(-) diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index b2b289d4cd2..ee6ed513fad 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -7,6 +7,12 @@ return { name = 'custom-task', lazy = false, config = function() - require('custom.task').setup() + require('custom.task').setup({ + float = { + width = 0.6, + height = 0.5, + border = 'single', + }, + }) end, -} \ No newline at end of file +} diff --git a/lua/custom/task/init.lua b/lua/custom/task/init.lua index d6176f10809..8389d879858 100644 --- a/lua/custom/task/init.lua +++ b/lua/custom/task/init.lua @@ -1,36 +1,64 @@ -local Module = {} +local M = {} -Module.setup = function() end +M._win = nil +M._buf = nil +M._last_task = nil +M._options = {} -local function centered_float_size() - local width = math.floor(vim.o.columns * 0.8) - local height = math.floor(vim.o.lines * 0.8) - local row = math.floor((vim.o.lines - height) / 2) - local col = math.floor((vim.o.columns - width) / 2) - return width, height, row, col +local defaults = { + float = { + width = 0.8, + height = 0.8, + border = 'rounded', + }, + scroll = { + auto = true, + }, + keymaps = { + rerun = 'rt' + }, +} + +local function setup_global_keymaps() + if M._options.keymaps and M._options.keymaps.rerun then + vim.keymap.set('n', M._options.keymaps.rerun, function() + if M._last_task then + M.execute_task(M._last_task) + else + vim.notify('No task has been run yet.', vim.log.levels.WARN) + end + end, { desc = '[R]erun last [T]ask' }) + end end -Module.get_tasks = function() - local response = vim.fn.system 'task --list --json' - local exit_code = vim.v.shell_error - - if exit_code ~= 0 then - vim.notify('Task command failed (missing Taskfile?)', vim.log.levels.ERROR) - return {} - end +function M.setup(opts) + vim.validate({ + opts = { opts, 'table', true } + }) + M._options = vim.tbl_deep_extend('force', {}, defaults, opts or {}) - local ok, data = pcall(vim.fn.json_decode, response) - if not ok or not data or not data.tasks then - vim.notify('Failed to parse task output.', vim.log.levels.ERROR) - return {} + if M._options.keymaps ~= false then + setup_global_keymaps() end +end - return data.tasks +local function float_size() + local cfg = M._options.float + local width = math.floor(vim.o.columns * (cfg.width or 0.8)) + local height = math.floor(vim.o.lines * (cfg.height or 0.8)) + local row = math.floor((vim.o.lines - height) / 2) + local col = math.floor((vim.o.columns - width) / 2) + return width, height, row, col, cfg.border or 'rounded' end -Module.execute_task = function(task) - local width, height, row, col = centered_float_size() +local function scroll_to_bottom() + vim.schedule(function() + pcall(vim.cmd, 'normal! G') + end) +end +local function create_terminal_window() + local width, height, row, col, border = float_size() local buf = vim.api.nvim_create_buf(false, true) local win = vim.api.nvim_open_win(buf, true, { relative = 'editor', @@ -39,48 +67,92 @@ Module.execute_task = function(task) width = width, height = height, style = 'minimal', - border = 'rounded', + border = border, }) - vim.api.nvim_set_current_buf(buf) - vim.fn.termopen('task ' .. task, { - on_stdout = function(_, _, _) - vim.api.nvim_command 'normal! G' - end, - on_stderr = function(_, _, _) - vim.api.nvim_command 'normal! G' - end, - on_exit = function() - vim.api.nvim_command 'normal! G' - end, - }) + return buf, win +end + +local function cleanup_terminal() + if M._win and vim.api.nvim_win_is_valid(M._win) then + vim.api.nvim_win_close(M._win, true) + end + if M._buf and vim.api.nvim_buf_is_valid(M._buf) then + vim.api.nvim_buf_delete(M._buf, { force = true }) + end +end +local function run_task_in_terminal(buf, task) + local opts = {} + if M._options.scroll.auto then + opts.on_stdout = scroll_to_bottom + opts.on_stderr = scroll_to_bottom + opts.on_exit = scroll_to_bottom + end + + local term_opts = next(opts) and opts or vim.empty_dict() + vim.fn.termopen('task ' .. task, term_opts) +end + +local function set_quit_key(buf, win) vim.keymap.set('n', 'q', function() - vim.api.nvim_win_close(win, true) + if vim.api.nvim_win_is_valid(win) then + vim.api.nvim_win_close(win, true) + end end, { buffer = buf, nowait = true, silent = true }) end -Module.on_choice = function(item) - Module.execute_task(item.name) +function M.execute_task(task) + cleanup_terminal() + local buf, win = create_terminal_window() + M._buf, M._win, M._last_task = buf, win, task + run_task_in_terminal(buf, task) + set_quit_key(buf, win) end -Module.open_window = function() - local tasks = Module.get_tasks() - if #tasks == 0 then - vim.notify('No tasks available', vim.log.levels.WARN) - return +function M.get_tasks() + if vim.fn.executable('task') ~= 1 then + vim.notify("'task' executable not found in PATH", vim.log.levels.ERROR) + return {} + end + local response = vim.fn.system 'task --list --json' + if vim.v.shell_error ~= 0 then + vim.notify('Task command failed (missing Taskfile?)', vim.log.levels.ERROR) + return {} + end + local ok, data = pcall(vim.fn.json_decode, response) + if not ok or not data or not data.tasks then + vim.notify('Failed to parse task output.', vim.log.levels.ERROR) + return {} end + return data.tasks +end - local formatter = function(task) - return string.format('%-20s %s', task.name, task.desc or '') +function M.on_choice(item) + if not item or not item.name then + vim.notify('Invalid task selection', vim.log.levels.WARN) + return end + M.execute_task(item.name) +end - vim.ui.select(tasks, { prompt = 'Task:', format_item = formatter }, Module.on_choice) +function M.open_window() + local tasks = M.get_tasks() + if #tasks == 0 then + vim.notify('No tasks available', vim.log.levels.WARN) + return + end + vim.ui.select(tasks, { + prompt = 'Task:', + format_item = function(task) + return string.format('%-20s %s', task.name, task.desc or '') + end, + }, M.on_choice) end -local complete = function(ArgLead, _, _) +local function complete(ArgLead, _, _) local matches = {} - for _, task in ipairs(Module.get_tasks()) do + for _, task in ipairs(M.get_tasks()) do if task.name:lower():match('^' .. ArgLead:lower()) then table.insert(matches, task.name) end @@ -91,10 +163,18 @@ end vim.api.nvim_create_user_command('Task', function(input) if input.args ~= '' then - Module.execute_task(input.args) + M.execute_task(input.args) else - Module.open_window() + M.open_window() end end, { bang = true, desc = 'Run tasks defined in a Taskfile', nargs = '?', complete = complete }) -return Module +vim.api.nvim_create_user_command('TaskRerun', function() + if not M._last_task then + vim.notify('No task has been run yet.', vim.log.levels.WARN) + return + end + M.execute_task(M._last_task) +end, { desc = 'Rerun last Task' }) + +return M From d45f53b6baab31a3e7d10f3696ceeb5daf4315e6 Mon Sep 17 00:00:00 2001 From: dario Date: Wed, 30 Apr 2025 21:56:11 +0200 Subject: [PATCH 09/17] docs: add readme for task plugin --- lua/custom/task/README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 lua/custom/task/README.md diff --git a/lua/custom/task/README.md b/lua/custom/task/README.md new file mode 100644 index 00000000000..c858bcc9cbf --- /dev/null +++ b/lua/custom/task/README.md @@ -0,0 +1,32 @@ +# Task + +A simple plugin for [taskfiles](https://taskfile.dev/) + +## Options + +```lua +return { + dir = vim.fn.stdpath('config') .. '/lua/custom/task', + name = 'custom-task', + lazy = false, + config = function() + require('custom.task').setup({ + float = { + width = 0.7, -- Percentage of the screen width + height = 0.7, -- Percentage of the screen height + border = 'single', -- Border style + }, + scroll = { + auto = true, -- Automatically scroll to the bottom when new output is added + }, + keymaps = { + rerun = 'rt' -- Keymap to rerun the last task + }, + }) + end, +} +``` + +### Commands +- `:Task` โ€” select and run a task from the Taskfile +- `:TaskRerun` โ€” rerun the last task From b5f34cb9edace704d020f32f7992337fd6448b2c Mon Sep 17 00:00:00 2001 From: dario Date: Thu, 1 May 2025 22:22:03 +0200 Subject: [PATCH 10/17] feat: add preview of tasks to task plugin --- lua/custom/task/init.lua | 159 +++++++++++++++++++++++++++++++++++---- 1 file changed, 143 insertions(+), 16 deletions(-) diff --git a/lua/custom/task/init.lua b/lua/custom/task/init.lua index 8389d879858..c4d9d912bf3 100644 --- a/lua/custom/task/init.lua +++ b/lua/custom/task/init.lua @@ -1,4 +1,5 @@ local M = {} +local preview_ns = vim.api.nvim_create_namespace 'TaskPreview' M._win = nil M._buf = nil @@ -15,7 +16,7 @@ local defaults = { auto = true, }, keymaps = { - rerun = 'rt' + rerun = 'rt', }, } @@ -32,9 +33,9 @@ local function setup_global_keymaps() end function M.setup(opts) - vim.validate({ - opts = { opts, 'table', true } - }) + vim.validate { + opts = { opts, 'table', true }, + } M._options = vim.tbl_deep_extend('force', {}, defaults, opts or {}) if M._options.keymaps ~= false then @@ -42,33 +43,49 @@ function M.setup(opts) end end -local function float_size() - local cfg = M._options.float - local width = math.floor(vim.o.columns * (cfg.width or 0.8)) - local height = math.floor(vim.o.lines * (cfg.height or 0.8)) +local function calculate_dimensions(percent_width, percent_height) + local width = math.floor(vim.o.columns * percent_width) + local height = math.floor(vim.o.lines * percent_height) local row = math.floor((vim.o.lines - height) / 2) local col = math.floor((vim.o.columns - width) / 2) + return width, height, row, col +end + +local function float_size() + local cfg = M._options.float + local width, height, row, col = calculate_dimensions(cfg.width or 0.8, cfg.height or 0.8) return width, height, row, col, cfg.border or 'rounded' end local function scroll_to_bottom() vim.schedule(function() - pcall(vim.cmd, 'normal! G') + vim.cmd 'normal! G' end) end +local function open_floating_win(buf, opts, enter) + return vim.api.nvim_open_win( + buf, + enter or false, + vim.tbl_extend('force', { + relative = 'editor', + style = 'minimal', + border = 'single', + }, opts or {}) + ) +end + local function create_terminal_window() local width, height, row, col, border = float_size() local buf = vim.api.nvim_create_buf(false, true) - local win = vim.api.nvim_open_win(buf, true, { - relative = 'editor', + local win = open_floating_win(buf, { row = row, col = col, width = width, height = height, - style = 'minimal', border = border, - }) + }, true) + vim.api.nvim_set_current_buf(buf) return buf, win end @@ -82,6 +99,23 @@ local function cleanup_terminal() end end +local function clean_dry_output(lines) + local cleaned = {} + for _, line in ipairs(lines) do + local cleaned_line = line:gsub('^task:%s+%[.-%]%s*', '') + table.insert(cleaned, cleaned_line) + end + return cleaned +end + +local function highlight_line(buf, ns, line) + local content = vim.api.nvim_buf_get_lines(buf, line, line + 1, false)[1] or '' + vim.api.nvim_buf_set_extmark(buf, ns, line, 0, { + end_col = #content, + hl_group = 'Visual', + }) +end + local function run_task_in_terminal(buf, task) local opts = {} if M._options.scroll.auto then @@ -111,7 +145,7 @@ function M.execute_task(task) end function M.get_tasks() - if vim.fn.executable('task') ~= 1 then + if vim.fn.executable 'task' ~= 1 then vim.notify("'task' executable not found in PATH", vim.log.levels.ERROR) return {} end @@ -130,7 +164,7 @@ end function M.on_choice(item) if not item or not item.name then - vim.notify('Invalid task selection', vim.log.levels.WARN) + vim.notify("Invalid task selection: no 'name' field", vim.log.levels.WARN) return end M.execute_task(item.name) @@ -150,6 +184,99 @@ function M.open_window() }, M.on_choice) end +function M.select_task_with_preview() + local tasks = M.get_tasks() + if #tasks == 0 then + vim.notify('No tasks available', vim.log.levels.WARN) + return + end + + local total_width, total_height, row, col = calculate_dimensions(0.8, 0.6) + local list_width = math.floor(total_width * 0.4) + local preview_width = total_width - list_width - 2 + local list_buf = vim.api.nvim_create_buf(false, true) + local preview_buf = vim.api.nvim_create_buf(false, true) + + local lines = {} + for _, task in ipairs(tasks) do + table.insert(lines, string.format('%-20s %s', task.name, task.desc or '')) + end + vim.api.nvim_buf_set_lines(list_buf, 0, -1, false, lines) + + local list_win = open_floating_win(list_buf, { + row = row, + col = col, + width = list_width, + height = total_height, + title = 'Tasks', + title_pos = 'center', + }, true) + + local preview_win = open_floating_win(preview_buf, { + row = row, + col = col + list_width + 2, + width = preview_width, + height = total_height, + title = 'Preview', + title_pos = 'center', + }, false) + + local current_line = 1 + local line = current_line - 1 + highlight_line(list_buf, preview_ns, line) + + local function update_preview(index) + local task = tasks[index] + if not task then + return + end + local output = vim.fn.system { 'task', task.name, '--dry' } + local cleaned_output = clean_dry_output(vim.split(output, '\n')) + vim.api.nvim_buf_set_lines(preview_buf, 0, -1, false, cleaned_output) + end + + update_preview(current_line) + + vim.keymap.set('n', '', function() + local task = tasks[current_line] + if task then + vim.api.nvim_win_close(list_win, true) + vim.api.nvim_win_close(preview_win, true) + M.execute_task(task.name) + end + end, { buffer = list_buf }) + + vim.keymap.set('n', 'q', function() + vim.api.nvim_win_close(list_win, true) + vim.api.nvim_win_close(preview_win, true) + end, { buffer = list_buf }) + + vim.keymap.set('n', '', function() + vim.api.nvim_win_close(list_win, true) + vim.api.nvim_win_close(preview_win, true) + end, { buffer = list_buf }) + + vim.keymap.set('n', 'j', function() + if current_line < #tasks then + vim.api.nvim_buf_clear_namespace(list_buf, preview_ns, 0, -1) + current_line = current_line + 1 + highlight_line(list_buf, preview_ns, current_line - 1) + update_preview(current_line) + vim.api.nvim_win_set_cursor(list_win, { current_line, 0 }) + end + end, { buffer = list_buf }) + + vim.keymap.set('n', 'k', function() + if current_line > 1 then + vim.api.nvim_buf_clear_namespace(list_buf, preview_ns, 0, -1) + current_line = current_line - 1 + highlight_line(list_buf, preview_ns, current_line - 1) + update_preview(current_line) + vim.api.nvim_win_set_cursor(list_win, { current_line, 0 }) + end + end, { buffer = list_buf }) +end + local function complete(ArgLead, _, _) local matches = {} for _, task in ipairs(M.get_tasks()) do @@ -165,7 +292,7 @@ vim.api.nvim_create_user_command('Task', function(input) if input.args ~= '' then M.execute_task(input.args) else - M.open_window() + M.select_task_with_preview() end end, { bang = true, desc = 'Run tasks defined in a Taskfile', nargs = '?', complete = complete }) From c0c62c5a82f9e1d7bfe3b27dbc5084109c61cfc9 Mon Sep 17 00:00:00 2001 From: dario Date: Sat, 3 May 2025 23:38:03 +0200 Subject: [PATCH 11/17] use dasvh/taskfile.nvim --- lua/custom/plugins/init.lua | 8 +- lua/custom/task/README.md | 32 ---- lua/custom/task/init.lua | 307 ------------------------------------ 3 files changed, 4 insertions(+), 343 deletions(-) delete mode 100644 lua/custom/task/README.md delete mode 100644 lua/custom/task/init.lua diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index ee6ed513fad..c037450c47b 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,17 +2,17 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information +-- nvim/lua/custom/plugins/taskfile.lua return { - dir = vim.fn.stdpath('config') .. '/lua/custom/task', - name = 'custom-task', + 'dasvh/taskfile.nvim', lazy = false, config = function() - require('custom.task').setup({ + require('taskfile').setup { float = { width = 0.6, height = 0.5, border = 'single', }, - }) + } end, } diff --git a/lua/custom/task/README.md b/lua/custom/task/README.md deleted file mode 100644 index c858bcc9cbf..00000000000 --- a/lua/custom/task/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Task - -A simple plugin for [taskfiles](https://taskfile.dev/) - -## Options - -```lua -return { - dir = vim.fn.stdpath('config') .. '/lua/custom/task', - name = 'custom-task', - lazy = false, - config = function() - require('custom.task').setup({ - float = { - width = 0.7, -- Percentage of the screen width - height = 0.7, -- Percentage of the screen height - border = 'single', -- Border style - }, - scroll = { - auto = true, -- Automatically scroll to the bottom when new output is added - }, - keymaps = { - rerun = 'rt' -- Keymap to rerun the last task - }, - }) - end, -} -``` - -### Commands -- `:Task` โ€” select and run a task from the Taskfile -- `:TaskRerun` โ€” rerun the last task diff --git a/lua/custom/task/init.lua b/lua/custom/task/init.lua deleted file mode 100644 index c4d9d912bf3..00000000000 --- a/lua/custom/task/init.lua +++ /dev/null @@ -1,307 +0,0 @@ -local M = {} -local preview_ns = vim.api.nvim_create_namespace 'TaskPreview' - -M._win = nil -M._buf = nil -M._last_task = nil -M._options = {} - -local defaults = { - float = { - width = 0.8, - height = 0.8, - border = 'rounded', - }, - scroll = { - auto = true, - }, - keymaps = { - rerun = 'rt', - }, -} - -local function setup_global_keymaps() - if M._options.keymaps and M._options.keymaps.rerun then - vim.keymap.set('n', M._options.keymaps.rerun, function() - if M._last_task then - M.execute_task(M._last_task) - else - vim.notify('No task has been run yet.', vim.log.levels.WARN) - end - end, { desc = '[R]erun last [T]ask' }) - end -end - -function M.setup(opts) - vim.validate { - opts = { opts, 'table', true }, - } - M._options = vim.tbl_deep_extend('force', {}, defaults, opts or {}) - - if M._options.keymaps ~= false then - setup_global_keymaps() - end -end - -local function calculate_dimensions(percent_width, percent_height) - local width = math.floor(vim.o.columns * percent_width) - local height = math.floor(vim.o.lines * percent_height) - local row = math.floor((vim.o.lines - height) / 2) - local col = math.floor((vim.o.columns - width) / 2) - return width, height, row, col -end - -local function float_size() - local cfg = M._options.float - local width, height, row, col = calculate_dimensions(cfg.width or 0.8, cfg.height or 0.8) - return width, height, row, col, cfg.border or 'rounded' -end - -local function scroll_to_bottom() - vim.schedule(function() - vim.cmd 'normal! G' - end) -end - -local function open_floating_win(buf, opts, enter) - return vim.api.nvim_open_win( - buf, - enter or false, - vim.tbl_extend('force', { - relative = 'editor', - style = 'minimal', - border = 'single', - }, opts or {}) - ) -end - -local function create_terminal_window() - local width, height, row, col, border = float_size() - local buf = vim.api.nvim_create_buf(false, true) - local win = open_floating_win(buf, { - row = row, - col = col, - width = width, - height = height, - border = border, - }, true) - - vim.api.nvim_set_current_buf(buf) - return buf, win -end - -local function cleanup_terminal() - if M._win and vim.api.nvim_win_is_valid(M._win) then - vim.api.nvim_win_close(M._win, true) - end - if M._buf and vim.api.nvim_buf_is_valid(M._buf) then - vim.api.nvim_buf_delete(M._buf, { force = true }) - end -end - -local function clean_dry_output(lines) - local cleaned = {} - for _, line in ipairs(lines) do - local cleaned_line = line:gsub('^task:%s+%[.-%]%s*', '') - table.insert(cleaned, cleaned_line) - end - return cleaned -end - -local function highlight_line(buf, ns, line) - local content = vim.api.nvim_buf_get_lines(buf, line, line + 1, false)[1] or '' - vim.api.nvim_buf_set_extmark(buf, ns, line, 0, { - end_col = #content, - hl_group = 'Visual', - }) -end - -local function run_task_in_terminal(buf, task) - local opts = {} - if M._options.scroll.auto then - opts.on_stdout = scroll_to_bottom - opts.on_stderr = scroll_to_bottom - opts.on_exit = scroll_to_bottom - end - - local term_opts = next(opts) and opts or vim.empty_dict() - vim.fn.termopen('task ' .. task, term_opts) -end - -local function set_quit_key(buf, win) - vim.keymap.set('n', 'q', function() - if vim.api.nvim_win_is_valid(win) then - vim.api.nvim_win_close(win, true) - end - end, { buffer = buf, nowait = true, silent = true }) -end - -function M.execute_task(task) - cleanup_terminal() - local buf, win = create_terminal_window() - M._buf, M._win, M._last_task = buf, win, task - run_task_in_terminal(buf, task) - set_quit_key(buf, win) -end - -function M.get_tasks() - if vim.fn.executable 'task' ~= 1 then - vim.notify("'task' executable not found in PATH", vim.log.levels.ERROR) - return {} - end - local response = vim.fn.system 'task --list --json' - if vim.v.shell_error ~= 0 then - vim.notify('Task command failed (missing Taskfile?)', vim.log.levels.ERROR) - return {} - end - local ok, data = pcall(vim.fn.json_decode, response) - if not ok or not data or not data.tasks then - vim.notify('Failed to parse task output.', vim.log.levels.ERROR) - return {} - end - return data.tasks -end - -function M.on_choice(item) - if not item or not item.name then - vim.notify("Invalid task selection: no 'name' field", vim.log.levels.WARN) - return - end - M.execute_task(item.name) -end - -function M.open_window() - local tasks = M.get_tasks() - if #tasks == 0 then - vim.notify('No tasks available', vim.log.levels.WARN) - return - end - vim.ui.select(tasks, { - prompt = 'Task:', - format_item = function(task) - return string.format('%-20s %s', task.name, task.desc or '') - end, - }, M.on_choice) -end - -function M.select_task_with_preview() - local tasks = M.get_tasks() - if #tasks == 0 then - vim.notify('No tasks available', vim.log.levels.WARN) - return - end - - local total_width, total_height, row, col = calculate_dimensions(0.8, 0.6) - local list_width = math.floor(total_width * 0.4) - local preview_width = total_width - list_width - 2 - local list_buf = vim.api.nvim_create_buf(false, true) - local preview_buf = vim.api.nvim_create_buf(false, true) - - local lines = {} - for _, task in ipairs(tasks) do - table.insert(lines, string.format('%-20s %s', task.name, task.desc or '')) - end - vim.api.nvim_buf_set_lines(list_buf, 0, -1, false, lines) - - local list_win = open_floating_win(list_buf, { - row = row, - col = col, - width = list_width, - height = total_height, - title = 'Tasks', - title_pos = 'center', - }, true) - - local preview_win = open_floating_win(preview_buf, { - row = row, - col = col + list_width + 2, - width = preview_width, - height = total_height, - title = 'Preview', - title_pos = 'center', - }, false) - - local current_line = 1 - local line = current_line - 1 - highlight_line(list_buf, preview_ns, line) - - local function update_preview(index) - local task = tasks[index] - if not task then - return - end - local output = vim.fn.system { 'task', task.name, '--dry' } - local cleaned_output = clean_dry_output(vim.split(output, '\n')) - vim.api.nvim_buf_set_lines(preview_buf, 0, -1, false, cleaned_output) - end - - update_preview(current_line) - - vim.keymap.set('n', '', function() - local task = tasks[current_line] - if task then - vim.api.nvim_win_close(list_win, true) - vim.api.nvim_win_close(preview_win, true) - M.execute_task(task.name) - end - end, { buffer = list_buf }) - - vim.keymap.set('n', 'q', function() - vim.api.nvim_win_close(list_win, true) - vim.api.nvim_win_close(preview_win, true) - end, { buffer = list_buf }) - - vim.keymap.set('n', '', function() - vim.api.nvim_win_close(list_win, true) - vim.api.nvim_win_close(preview_win, true) - end, { buffer = list_buf }) - - vim.keymap.set('n', 'j', function() - if current_line < #tasks then - vim.api.nvim_buf_clear_namespace(list_buf, preview_ns, 0, -1) - current_line = current_line + 1 - highlight_line(list_buf, preview_ns, current_line - 1) - update_preview(current_line) - vim.api.nvim_win_set_cursor(list_win, { current_line, 0 }) - end - end, { buffer = list_buf }) - - vim.keymap.set('n', 'k', function() - if current_line > 1 then - vim.api.nvim_buf_clear_namespace(list_buf, preview_ns, 0, -1) - current_line = current_line - 1 - highlight_line(list_buf, preview_ns, current_line - 1) - update_preview(current_line) - vim.api.nvim_win_set_cursor(list_win, { current_line, 0 }) - end - end, { buffer = list_buf }) -end - -local function complete(ArgLead, _, _) - local matches = {} - for _, task in ipairs(M.get_tasks()) do - if task.name:lower():match('^' .. ArgLead:lower()) then - table.insert(matches, task.name) - end - end - table.sort(matches) - return matches -end - -vim.api.nvim_create_user_command('Task', function(input) - if input.args ~= '' then - M.execute_task(input.args) - else - M.select_task_with_preview() - end -end, { bang = true, desc = 'Run tasks defined in a Taskfile', nargs = '?', complete = complete }) - -vim.api.nvim_create_user_command('TaskRerun', function() - if not M._last_task then - vim.notify('No task has been run yet.', vim.log.levels.WARN) - return - end - M.execute_task(M._last_task) -end, { desc = 'Rerun last Task' }) - -return M From fa2ed01113c6e73efbeae666f050ce2717826dd8 Mon Sep 17 00:00:00 2001 From: dario Date: Wed, 8 Oct 2025 09:40:58 +0200 Subject: [PATCH 12/17] feat: use pylint --- lua/kickstart/plugins/lint.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/kickstart/plugins/lint.lua b/lua/kickstart/plugins/lint.lua index 907c6bf3e31..c7dcc82869b 100644 --- a/lua/kickstart/plugins/lint.lua +++ b/lua/kickstart/plugins/lint.lua @@ -7,6 +7,7 @@ return { local lint = require 'lint' lint.linters_by_ft = { markdown = { 'markdownlint' }, + python = { 'pylint' }, } -- To allow other plugins to add linters to require('lint').linters_by_ft, From 365ea56a98c089839d68acfd1041d6e523aa415c Mon Sep 17 00:00:00 2001 From: dario Date: Wed, 8 Oct 2025 09:43:05 +0200 Subject: [PATCH 13/17] fix: close behaviour of neo-tree and don't hide dotfiles --- lua/kickstart/plugins/neo-tree.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index bd4422695aa..8e195ffd06a 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -3,6 +3,7 @@ return { 'nvim-neo-tree/neo-tree.nvim', + lazy = false, version = '*', dependencies = { 'nvim-lua/plenary.nvim', @@ -14,12 +15,16 @@ return { { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, }, opts = { + close_if_last_window = true, filesystem = { window = { mappings = { ['\\'] = 'close_window', }, }, + filtered_items = { + hide_dotfiles = false, + }, }, }, } From 9357b66509dca47343006170166e79742647b736 Mon Sep 17 00:00:00 2001 From: dario Date: Wed, 8 Oct 2025 09:44:39 +0200 Subject: [PATCH 14/17] feat: use yamlls and use additional formatters --- init.lua | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 70 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index fa7834f687d..f23510e8661 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,6 @@ --[[ +TODO: fix leader key for telescope from neo-tree What is Kickstart? Kickstart.nvim is *not* a distribution. @@ -44,7 +45,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -114,6 +115,14 @@ vim.opt.scrolloff = 10 -- See `:help 'confirm'` vim.opt.confirm = true +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +vim.filetype.add { + filename = { ['Taskfile'] = 'yaml' }, + pattern = { ['.*/%.taskfiles/.*%.ya?ml'] = 'yaml' }, +} + -- highlight ExtraWhitespace -- TODO: does not seem to clear all whitespace (-> did not work for yaml file) vim.api.nvim_set_hl(0, 'ExtraWhitespace', { @@ -644,7 +653,7 @@ require('lazy').setup({ -- clangd = {}, gopls = {}, bashls = {}, - -- pyright = {}, + pyright = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- @@ -652,7 +661,7 @@ require('lazy').setup({ -- https://github.com/pmizio/typescript-tools.nvim -- -- But for many setups, the LSP (`ts_ls`) will work just fine - -- ts_ls = {}, + ts_ls = {}, -- lua_ls = { @@ -669,6 +678,39 @@ require('lazy').setup({ }, }, }, + yamlls = { + settings = { + yaml = { + validate = true, + hover = true, + completion = true, + format = { enable = false }, + kubernetes = { enable = true }, + schemaStore = { enable = true }, + schemas = { + ['https://raw.githubusercontent.com/compose-spec/compose-spec/refs/heads/main/schema/compose-spec.json'] = { + 'docker-compose*.yml', + 'docker-compose*.yaml', + 'compose*.yml', + 'compose*.yaml', + }, + ['https://json.schemastore.org/github-workflow.json'] = { + '.github/workflows/*.yml', + '.github/workflows/*.yaml', + }, + ['https://json.schemastore.org/gitlab-ci.json'] = { + '.gitlab-ci.yml', + '.gitlab-ci.yaml', + }, + ['https://taskfile.dev/schema.json'] = { + 'Taskfile', + 'Taskfile.yml', + 'Taskfile.yaml', + }, + }, + }, + }, + }, } -- Ensure the servers and tools above are installed @@ -739,6 +781,14 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + yaml = { 'prettier' }, + -- markdown = { 'prettier' }, + python = { 'black' }, + terraform = { 'terraform_fmt' }, + tex = { 'latexindent' }, + sql = { 'prettier' }, + -- sql = { 'sql_formatter' }, + -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -866,6 +916,19 @@ require('lazy').setup({ end, }, + { + 'Piotr1215/presenterm.nvim', + build = false, + config = function() + require('presenterm').setup { + default_keybindings = true, + picker = { + provider = 'telescope', + }, + } + end, + }, + { -- You can easily change to a different colorscheme. -- Change the name of the colorscheme plugin below, and then -- change the command in the config to whatever the name of that colorscheme is. @@ -944,7 +1007,7 @@ require('lazy').setup({ -- the list of additional_vim_regex_highlighting and disabled languages for indent. additional_vim_regex_highlighting = { 'ruby' }, }, - indent = { enable = true, disable = { 'ruby' } }, + indent = { enable = true, disable = { 'ruby', 'yaml' } }, }, -- There are additional nvim-treesitter modules that you can use to interact -- with nvim-treesitter. You should go explore a few and see what interests you: @@ -965,9 +1028,9 @@ require('lazy').setup({ -- -- require 'kickstart.plugins.debug', -- require 'kickstart.plugins.indent_line', - -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.lint', + require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.neo-tree', -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` From 9e8a0aed6ece2eaa311682a7ef71f4c9670742a9 Mon Sep 17 00:00:00 2001 From: dario Date: Wed, 8 Oct 2025 12:38:05 +0200 Subject: [PATCH 15/17] update keybinds --- init.lua | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index d4dab21a930..5f38facd789 100644 --- a/init.lua +++ b/init.lua @@ -175,6 +175,12 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the upper win -- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) -- vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) +-- helper to jump to diagnostic +local function diagnostic_jump(count, opts) + opts = vim.tbl_extend('force', { count = count, wrap = true, float = true }, opts or {}) + vim.diagnostic.jump(opts) +end + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -328,6 +334,9 @@ require('lazy').setup({ { 's', group = '[S]earch' }, { 't', group = '[T]oggle' }, { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, + { 'r', group = '[R]efactor' }, + { 'g', group = '[G]oto' }, + { 'e', group = '[E]rror Diagnostics' }, }, }, }, @@ -418,6 +427,22 @@ require('lazy').setup({ vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, { desc = '[R]e[n]ame' }) + vim.keymap.set('n', 'rr', vim.lsp.buf.references, { desc = '[R]eferences' }) + vim.keymap.set('n', 'gd', builtin.lsp_definitions, { desc = '[G]oto [D]efinition' }) + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, { desc = '[G]oto [D]eclaration' }) + vim.keymap.set('n', 'gi', builtin.lsp_implementations, { desc = '[G]oto [I]mplementation' }) + + vim.keymap.set('n', 'gb', '', { desc = '[G]o [B]ack' }) + vim.keymap.set('n', 'gf', '', { desc = '[G]o [F]orward' }) + + vim.keymap.set('n', 'en', function() + diagnostic_jump(vim.v.count1) + end, { desc = '[E]rror [N]ext' }) + vim.keymap.set('n', 'ep', function() + diagnostic_jump(-vim.v.count1) + end, { desc = '[E]rror [P]revious' }) + -- Slightly advanced example of overriding default behavior and theme vim.keymap.set('n', '/', function() -- You can pass additional configuration to Telescope to change the theme, layout, etc. @@ -1014,7 +1039,7 @@ require('lazy').setup({ require 'kickstart.plugins.lint', require 'kickstart.plugins.autopairs', require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. @@ -1026,6 +1051,7 @@ require('lazy').setup({ -- Or use telescope! -- In normal mode type `sh` then write `lazy.nvim-plugin` -- you can continue same window with `sr` which resumes last telescope search + -- }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the From 73cd1afd7e94b97599119ad540b3fd37650406f9 Mon Sep 17 00:00:00 2001 From: dario Date: Sun, 26 Oct 2025 13:42:52 +0100 Subject: [PATCH 16/17] fix: set spelllang and use correct schema for gitlab-ci.yml --- init.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 5f38facd789..29197ea0510 100644 --- a/init.lua +++ b/init.lua @@ -106,6 +106,19 @@ vim.o.splitbelow = true vim.o.list = true vim.opt.listchars = { tab = 'ยป ', trail = 'ยท', nbsp = 'โฃ' } +vim.opt.spelllang = { 'en_us', 'de_ch' } +vim.api.nvim_create_autocmd('FileType', { + pattern = { 'markdown', 'gitcommit', 'text', 'rst', 'tex' }, + callback = function() + vim.opt_local.spell = true + end, +}) + +-- curl -fLo ~/.config/nvim/spell/de.utf-8.spl https://ftp.nluug.nl/pub/vim/runtime/spell/de.utf-8.spl +-- curl -fLo ~/.config/nvim/spell/de.utf-8.sug https://ftp.nluug.nl/pub/vim/runtime/spell/de.utf-8.sug +-- curl -fLo ~/.config/nvim/spell/en.utf-8.spl https://ftp.nluug.nl/pub/vim/runtime/spell/en.utf-8.spl +-- curl -fLo ~/.config/nvim/spell/en.utf-8.sug https://ftp.nluug.nl/pub/vim/runtime/spell/en.utf-8.sug + -- Preview substitutions live, as you type! vim.o.inccommand = 'split' @@ -725,7 +738,9 @@ require('lazy').setup({ '.github/workflows/*.yml', '.github/workflows/*.yaml', }, - ['https://json.schemastore.org/gitlab-ci.json'] = { + ['https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json'] = { + 'cicd/**/*.yml', + 'cicd/**/*.yaml', '.gitlab-ci.yml', '.gitlab-ci.yaml', }, From ff1abe53ed7a5ca93153bd54d6232438f6d25271 Mon Sep 17 00:00:00 2001 From: dario Date: Fri, 17 Apr 2026 14:24:46 +0200 Subject: [PATCH 17/17] feat: add spelling help to telescope; fix indent --- init.lua | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 29197ea0510..ebdd492ab93 100644 --- a/init.lua +++ b/init.lua @@ -208,9 +208,9 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) --- Set correct indendation for Go files +-- Set correct indendation for Go/templ files vim.api.nvim_create_autocmd('FileType', { - pattern = 'go', + pattern = { 'go', 'templ' }, callback = function() vim.bo.tabstop = 4 vim.bo.shiftwidth = 4 @@ -219,6 +219,16 @@ vim.api.nvim_create_autocmd('FileType', { end, }) +vim.api.nvim_create_autocmd('FileType', { + pattern = { 'typescript', 'json', 'jsonc' }, + callback = function() + vim.bo.tabstop = 2 + vim.bo.shiftwidth = 2 + vim.bo.softtabstop = 2 + vim.bo.expandtab = false + end, +}) + -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' @@ -348,6 +358,7 @@ require('lazy').setup({ { 't', group = '[T]oggle' }, { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, { 'r', group = '[R]efactor' }, + { 'sp', group = '[Sp]elling' }, { 'g', group = '[G]oto' }, { 'e', group = '[E]rror Diagnostics' }, }, @@ -440,6 +451,23 @@ require('lazy').setup({ vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + local themes = require 'telescope.themes' + vim.keymap.set('n', 'sps', function() + builtin.spell_suggest(themes.get_cursor()) + end, { desc = '[sp]elling: [s]uggestions ' }) + + -- toggle spell + vim.keymap.set('n', 'spt', function() + vim.wo.spell = not vim.wo.spell + vim.notify('spell: ' .. (vim.wo.spell and 'ON' or 'OFF')) + end, { desc = '[sp]elling: [t]oggle' }) + + vim.keymap.set('n', 'spg', 'zg', { desc = '[sp]elling: mark as [g]ood', silent = true }) + vim.keymap.set('n', 'spw', 'zw', { desc = '[sp]elling: mark as [w]rong', silent = true }) + vim.keymap.set('n', 'spu', 'zug', { desc = '[sp]elling: [u]ndo last mark', silent = true }) + vim.keymap.set('n', 'spn', ']s', { desc = '[sp]elling: [n]ext error', silent = true }) + vim.keymap.set('n', 'spp', '[s', { desc = '[sp]elling: [p]rev error', silent = true }) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, { desc = '[R]e[n]ame' }) vim.keymap.set('n', 'rr', vim.lsp.buf.references, { desc = '[R]eferences' }) vim.keymap.set('n', 'gd', builtin.lsp_definitions, { desc = '[G]oto [D]efinition' }) @@ -733,6 +761,8 @@ require('lazy').setup({ 'docker-compose*.yaml', 'compose*.yml', 'compose*.yaml', + 'dc*.yml', + 'dc*.yaml', }, ['https://json.schemastore.org/github-workflow.json'] = { '.github/workflows/*.yml', @@ -829,6 +859,9 @@ require('lazy').setup({ terraform = { 'terraform_fmt' }, tex = { 'latexindent' }, sql = { 'prettier' }, + templ = { 'templ' }, + javascript = { 'prettier' }, + typescript = { 'prettier' }, -- sql = { 'sql_formatter' }, -- Conform can also run multiple formatters sequentially