-
Notifications
You must be signed in to change notification settings - Fork 23
implement LSP-enum augend #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
I tested this, the enum cycling worked for me! I have an issue though, it slows down any non-enum cycling, so if I hover over a normal number and ctrl-a it will just go incredibly slow; about 1sec delay. probably because it defers from the lsp way too slowly but im not aware of these mechanisms. anyway you seem to be aware! note im testing in rust with this dial.nvim configreturn {
{
"monaqa/dial.nvim",
branch = "feat-augend-lsp",
keys = {
{ "<C-a>", function() require("dial.map").manipulate("increment", "normal") end, },
{ "<C-x>", function() require("dial.map").manipulate("decrement", "normal") end, },
{ "g<C-a>", function() require("dial.map").manipulate("increment", "gnormal") end, },
{ "g<C-x>", function() require("dial.map").manipulate("decrement", "gnormal") end, },
{ mode={"v"}, "<C-a>", function() require("dial.map").manipulate("increment", "visual") end, },
{ mode={"v"}, "<C-x>", function() require("dial.map").manipulate("decrement", "visual") end, },
{ mode={"v"}, "g<C-a>", function() require("dial.map").manipulate("increment", "gvisual") end, },
{ mode={"v"}, "g<C-x>", function() require("dial.map").manipulate("decrement", "gvisual") end, },
},
config = function()
local custom_lists = {
{"foo", "bar"},
{"tic", "tac", "toe"},
{"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"},
{"mon", "tue", "wed", "thu", "fri", "sat", "sun"},
{"january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"},
{"jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"},
{"spring", "summer", "fall", "winter"},
{"north", "northeast", "east", "southeast", "south", "southwest", "west", "northwest"},
{"true", "false"},
{"yes", "no"},
{"on", "off"},
{"enable", "disable"},
{"enabled", "disabled"},
{"null", "undefined"},
{"public", "private", "protected"},
{"let", "const", "var"},
{"and", "or"},
{"&&", "||", opts = {word=false}, },
{"if", "else", "elif"},
{"min", "max"},
{"minimum", "maximum"},
{"start", "end"},
{"first", "last"},
{"open", "close"},
{"read", "write"},
{"input", "output"},
{"in", "out"},
{"up", "down"},
{"left", "right"},
{"top", "bottom"},
{"width", "height"},
{"row", "column"},
{"div", "span"},
{"block", "inline", "flex", "grid"},
{"margin", "padding"},
{"absolute", "relative", "fixed", "sticky"},
{"seconds", "minutes", "hours", "days", "weeks", "months", "years"},
{"second", "minute", "hour", "day", "week", "month", "year"},
{"secs", "mins", "hrs", "days", "wks", "mos", "yrs"},
{"sec", "min", "hr", "day", "wk", "mo", "yr"},
}
local augend = require("dial.augend")
local augends = {
augend.lsp_enum.new({}),
augend.integer.alias.decimal_int,
augend.integer.alias.hex,
augend.integer.alias.octal,
augend.integer.alias.binary,
augend.date.alias["%Y/%m/%d"],
augend.date.alias["%H:%M:%S"],
augend.date.alias["%H:%M"],
augend.semver.alias.semver,
augend.constant.alias.alpha,
augend.constant.alias.Alpha,
augend.constant.alias.ja_weekday,
augend.constant.alias.ja_weekday_full,
augend.constant.alias.bool,
}
for _, list in ipairs(custom_lists) do
local options = {
word = true, -- Match whole words only by default
cyclic = true, -- Cycle through the list (e.g., "sunday" to "monday")
preserve_case = true, -- Preserve case (e.g., "True" to "False")
}
local elements = list
if list.opts then
local custom_opts = list.opts
list.opts = nil
for k, v in pairs(custom_opts) do
options[k] = v
end
end
options.elements = list
table.insert(augends, augend.constant.new(options))
end
require("dial.config").augends:register_group({
default = augends,
})
end,
},
}<details> |
|
just realized that you have a working draft. There's no point in providing warning I think, since if there's no lsp, we don't know where should that warning be provided. As for intuitive values, I think if users can just use lsp.hover first to get the available values, and then do the inc/dec. for the delay problem, it seems a bit hard to solve, my first idea is to use treesitter, for lua, enum values can only be in strings, can other languages, we only trigger when cursor is on a valid treesitter node type, just an idea. |
|
I implemented this using treesitter instead of lsp for zig, feel free to grab whatever you need if this is applicable to other languages only works when the sets/enums are declared in the current file but hey |
Closes #104, #106.
Problems
<C-a>/<C-x>