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
Add User experience menu #769
Conversation
Use the following
|
I realized my function definition style was not in line with other parts. I will address it later. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some comments with some optimizations/simplifications of the code. Also could we replace all of the print
calls with astronvim.notify
calls
lua/core/utils/ux.lua
Outdated
local relativenumber = vim.wo.relativenumber -- local to window | ||
if (number == false) and (relativenumber == false) then | ||
vim.wo.number = true | ||
vim.wo.relativenumber = false | ||
elseif (number == true) and (relativenumber == false) then | ||
vim.wo.number = false | ||
vim.wo.relativenumber = true | ||
elseif (number == false) and (relativenumber == true) then | ||
vim.wo.number = true | ||
vim.wo.relativenumber = true | ||
else -- (number == true) and (relativenumber == true) then | ||
vim.wo.number = false | ||
vim.wo.relativenumber = false | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we optimize and simplify this a little bit and do
if not number and not relativenumber then
vim.wo.number = true
elseif number and not relativenumber then
vim.wo.relativenumber = true
elseif number and relativenumber then
vim.wo.number = false
elseif not number and relativenumber then
vim.wo.relativenumber = false
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you pushed this change? I don't see it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I moved it to ui.lua
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant the rewrite I recommended for the number setting cycling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: I pushed to my ux branch which shows up on you account as osamu_ux
You may need to explicitly pull osamu_ux.
-- Change the number display modes.
function astronvim.change_number()
local number = vim.wo.number -- local to window
local relativenumber = vim.wo.relativenumber -- local to window
if not number and not relativenumber then
vim.wo.number = true
vim.wo.relativenumber = false
elseif number and not relativenumber then
vim.wo.number = false
vim.wo.relativenumber = true
elseif not number and relativenumber then
vim.wo.number = true
vim.wo.relativenumber = true
else -- number and relativenumber
vim.wo.number = false
vim.wo.relativenumber = false
end
vim.notify(
string.format("number=%s, relativenumber=%s",
bool2str(vim.wo.number),
bool2str(vim.wo.relativenumber)
)
)
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha,…I see your point sir.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done this time. Thanks
What about adding a toggle wrap? Sometimes when editing markdown files, I notice the author hard wraps, other times they don’t. Would be nice to have a quick toggle. Thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed you changed the prints to astronvim.echo
could you change them to astronvim.notify
?
|
Added ... (We can remove this if there is a objection.) |
I enhanced this for nvim-autopairs. |
I think this on-the-fly UI behavior change capability is getting matured now. One shortcoming is if filetype plugins or something else sets indent settings, vales set by Initial starting UI behavior customization should be a part of user_examples, I added them but I am 2 missing.
|
toggling for CMP and autopair needs some work. (Otherwise initial mode setting doesn't worrk and it always start active.) |
I think I need to work more on autopairs and cmp. Excuse me. |
I rebased to the current main. DIFF: https://github.com/AstroNvim/AstroNvim/compare/main..e7aefed4a0463b08df5f55de4c9beb362a2af8ea I think this is the best effort for me. I could not figure out how to start autopairs with disabled state cleanly. Thanks for interesting code base to play with. osamu |
Awesome, thanks so much @osamuaoki ! This is a great contribution and you have done a LOT of heavy lifting to get this PR to where it is :) I will take a look at what's currently there and merge it into a development branch to finish it up and get it merged. Thanks again :D |
Thanks. I think rebase conflict is minimal one since we both changed the last line of core/utils/init.lua. Please make both changes accepted. One thing I am concerned mildly is use of file name Your development branch seems to have |
I finally figured out how to start autopairs in disabled state. It was packer setup . Unlike, cmp, where we need a vim.g variable to toggle it, autopairs has internal state variable. So in theory, we don't need to create vim.g variable and have fancy user configuration trick. But that will be mind twisting to follow or write. So I chose simple code. So I can make all CMP/autopairs as opt-in feature. I like them when I write first code but for debugging, it is annoying. (I was not able to get v2 running cleanly. Do I need nvim 0.8 pre-release?) |
Oh yeah @osamuaoki currently v2 does require neovim 0.8 nightly. Sorry about that! |
Done: This has been implemented. I will squash changes and clean up ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@osamuaoki looks amazing! Thanks so much! Last thing though: could you reword your commit to say: feat(mappings)!: add UI menu feature
It's more of a mappings feature than a which-key one, also it does have a breaking change, so it needs the !
Several new mappings are introduced to control AstroNvim UI features. They are accessible from Normal mode under the "+UI" which-key menu. * Toggle autopairs (if module is available) * Toggle background * Toggle completion (if module is available) * Toggle signcolumn * Change indent setting * Change line numbering * Toggle spellcheck * Toggle URL highlight (relocated menu position) * Toggle wrap * Toggle syntax highlight For URL highlight, autopairs (nvim-autopairs) and completion (nvim-cmp), their starting states can be controlled by setting following vim global variables: * vim.g.highlighturl_enabled (no change with this commit) * vim.g.autopairs_enabled (new feature with this commit) * vim.g.cmp_enabled (new feature with this commit) * vim.g.syntax_on (`:syntax on` or `:syntax off` commands) For other vim native features, their corresponding starting states can be controlled by setting following standard vim options: * background * signcolumn * expandtab * tabstop * softtabstop * softwidth * number * relativenumber * spell * wrap * syntax The syntax option and toggling of it also affects treesetter. Signed-off-by: Osamu Aoki <osamu@debian.org>
Please note I have corresponding PR for web page. https://github.com/AstroNvim/astronvim.github.io/pull/13 In this PR, I also add "Configuration Mechanism" section so people can configure this package without reading the Lua source code around |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I am going to merge this into a dev branch and do a quick rebase on the v2
branch and merge it there since it has breaking changes. Thanks so so so much for your hard work on this one!
Finishing up at #816 |
Thanks. |
Building on discussion and tutoring at #764
I refactored original code set
Signed-off-by: Osamu Aoki osamu@debian.org