diff --git a/lua/colinzhao/lazy/lsp.lua b/lua/colinzhao/lazy/lsp.lua index 34a87c5c..1f83b700 100644 --- a/lua/colinzhao/lazy/lsp.lua +++ b/lua/colinzhao/lazy/lsp.lua @@ -134,6 +134,7 @@ return { -- LSP Configuration & Plugins -- - settings (table): Override the default settings passed when initializing the server. -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { + ocamllsp = {}, clangd = {}, bashls = {}, gopls = {}, @@ -183,6 +184,7 @@ return { -- LSP Configuration & Plugins 'stylua', -- Used to format Lua code 'black', -- Used to format Python code 'prettierd', + 'ocamlformat', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } diff --git a/lua/colinzhao/lazy/trouble.lua b/lua/colinzhao/lazy/trouble.lua index 0347802e..26dc6c48 100644 --- a/lua/colinzhao/lazy/trouble.lua +++ b/lua/colinzhao/lazy/trouble.lua @@ -1,3 +1,37 @@ +local tagIdx = {} +local tags = { + [0] = '', + [1] = 'FIX', + [2] = 'TODO', + [3] = 'WARN', + [4] = 'NOTE', +} +local numTags = 0 +for key, value in pairs(tags) do + tagIdx[value] = key + numTags = numTags + 1 +end + +local todoFilter = function(view, inc) + local f = view:get_filter 'tag' + local tag = tags[((tagIdx[f and f.filter.tag] or 0) + inc) % numTags] + view:filter({ tag = tag }, { + id = 'tag', + template = '{hl:Title}Filter:{hl} {tag}', + del = tag == '', + }) +end + +local diagnosticsFilter = function(view, inc) + local f = view:get_filter 'severity' + local severity = ((f and f.filter.severity or 0) + inc) % 5 + view:filter({ severity = severity }, { + id = 'severity', + template = '{hl:Title}Filter:{hl} {severity}', + del = severity == 0, + }) +end + return { 'folke/trouble.nvim', opts = { @@ -5,7 +39,44 @@ return { win = { size = 0.4, }, - }, -- for default options, refer to the configuration section for custom setup. + ---@type table + modes = { + diagnostics = { + mode = 'diagnostics', + keys = { + s = { + action = function(view) + diagnosticsFilter(view, 1) + end, + desc = 'Cycle Severity Filter Forward', + }, + S = { + action = function(view) + diagnosticsFilter(view, -1) + end, + desc = 'Cycle Severity Filter Backward', + }, + }, + }, + todo = { + mode = 'todo', + keys = { + s = { + action = function(view) + todoFilter(view, 1) + end, + desc = 'Cycle Tag Filter Forward', + }, + S = { + action = function(view) + todoFilter(view, -1) + end, + desc = 'Cycle Tag Filter Backward', + }, + }, + }, + }, + }, cmd = 'Trouble', keys = { { @@ -13,6 +84,11 @@ return { 'Trouble diagnostics toggle focus=true', desc = 'Diagnostics (Trouble)', }, + { + 'to', + 'Trouble todo toggle focus=true', + desc = 'Todo (Trouble)', + }, { 'ts', 'Trouble symbols toggle focus=true',