summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/vim/_defaults.lua
AgeCommit message (Collapse)AuthorFiles
2024-10-01feat(defaults): add default unimpaired style mappings (#28525)Gregory Anders1
2024-09-14fix(defaults): cannot remove "How-to disable mouse" menu item #30375Jaehwang Jung1
2024-09-05feat(defaults): popupmenu "Open in browser", "Go to definition" #30261Justin M. Keyes1
- Use the popup to expose more features such as LSP and gx. - Move the copy/paste items lower in the menu, they are lower priority.
2024-08-31feat(ui): gx: use url extmark attribute and tree-sitter directive (#30192)Gregory Anders1
Use the "url" extmark attribute as well as the "url" tree-sitter metadata key to determine if the cursor is over something Nvim considers a URL.
2024-06-15fix(defaults): default @/Q broken when 'ignorecase' is set (#29343)Jerry1
Problem: When 'ignorecase' is set, the default keymap Q and Q would exit visual mode. This issue was raised in #28287 and a fix was applied in #28289. However, `==` operator is subject to user `ignorecase` setting. Solution: Switching to `==#` operator would guarantee case sensitive comparison between visual mode and linewise visual mode. Co-authored-by: Kuanju Chen <kuanju.chen@mksinst.com>
2024-06-14fix(terminal): set local values of window options (#29326)zeertzjq1
2024-06-12refactor(terminal): move :terminal defaults to _defaults.luaGregory Anders1
2024-06-05fix(tui): move $COLORTERM check to _defaults.lua (#29197)Gregory Anders1
We currently check $COLORTERM in the TUI process to determine if the terminal supports 24 bit color (truecolor). If $COLORTERM is "truecolor" or "24bit" then we automatically assume that the terminal supports truecolor, but if $COLORTERM is set to any other value we still query the terminal. The `rgb` flag of the UI struct is a boolean which only indicates whether the UI supports truecolor, but does not have a 3rd state that we can use to represent "we don't know if the UI supports truecolor". We currently use `rgb=false` to represent this "we don't know" state, and we use XTGETTCAP and DECRQSS queries to determine at runtime if the terminal supports truecolor. However, if $COLORTERM is set to a value besides "truecolor" or "24bit" (e.g. "256" or "16) that is a clear indication that the terminal _does not_ support truecolor, so it is incorrect to treat `rgb=false` as "we don't know" in that case. Instead, in the TUI process we only check for the terminfo capabilities. This must be done in the TUI process because we do not have access to this information in the core Neovim process when `_defaults.lua` runs. If the TUI cannot determine truecolor support from terminfo alone, we set `rgb=false` to indicate "we don't know if the terminal supports truecolor yet, keep checking". When we get to `_defaults.lua`, we can then check $COLORTERM and only query the terminal if it is unset. This means that users can explicitly opt out of truecolor determination by setting `COLORTERM=256` (or similar) in their environment.
2024-05-28feat: add "jump" options to vim.diagnostic.config() (#29067)Gregory Anders1
Problem: There is no easy way to configure the behavior of the default diagnostic "jump" mappings. For example, some users way want to show the floating window, and some may not (likewise, some way want to only move between warnings/errors, or disable the "wrap" parameter). Solution: Add a "jump" table to vim.diagnostic.config() that sets default values for vim.diagnostic.jump(). Alternatives: Users can override the default mappings to use the exact options to vim.diagnostic.jump() that they want, but this has a couple issues: - While the default mappings are not complicated, they are also not trivial, so overriding them requires users to understand implementation details (specifically things like setting "count" properly). - If plugins want to change the default mappings, or configure the behavior in any way (e.g. floating window display), it becomes even harder for users to tweak specific behavior. vim.diagnostic.config() already works quite well as the "entry point" for tuning knobs with diagnostic UI elements, so this fits in nicely and composes well with existing mental models and idioms.
2024-05-28feat(defaults): use vim.diagnostic.jump() for default mappings (#29066)Gregory Anders1
This allows the mappings to work with a count and also enables new ]D and [D mappings to go to the last/first diagnostic in the buffer.
2024-05-24feat(defaults): add LSP default mappings (again) (#28650)Gregory Anders1
2024-05-24fix: show swapfile warning as a warning (#28971)Gregory Anders1
The new default SwapExists autocommand displays warning text (W325) but does not use the WarningMsg highlight group as other warnings do. Use the WARN log level when displaying this warning.
2024-05-24feat: allow gx to function for markdown linksdundargoc1
In other words, `gx` works regardless of where it was used in `[...](https://...)`. This only works on markdown buffers. Co-authored-by: ribru17 <ribru17@gmail.com>
2024-05-06revert: default LSP mappings (#28649)Gregory Anders1
Revert the default LSP mappings before the 0.10 release as these might need some further consideration. In particular, it's not clear if "c" prefixed maps in Normal mode are acceptable as defaults since they interfere with text objects or operator ranges. We will re-introduce default mappings at the beginning of the 0.11 release cycle, this reversion is only for the imminent 0.10 release.
2024-05-05fix(defaults): diagnostic mappings descriptions #28646Evgeni Chasnovski1
2024-05-03fix(vim.ui)!: change open() to return `result|nil, errmsg|nil` #28612Justin M. Keyes1
reverts e0d92b9cc20b58179599f53dfa74ca821935a539 #28502 Problem: `vim.ui.open()` has a `pcall()` like signature, under the assumption that this is the Lua idiom for returning result-or-error. However, the `result|nil, errmsg|nil` pattern: - has precedent in: - `io.open` - `vim.uv` (`:help luv-error-handling`) - has these advantages: - Can be used with `assert()`: ``` local result, err = assert(foobar()) ``` - Allows LuaLS to infer the type of `result`: ``` local result, err = foobar() if err then ... elseif result then ... end ``` Solution: - Revert to the `result|nil, errmsg|nil` pattern. - Document the pattern in our guidelines.
2024-04-30docs: misc #24163Justin M. Keyes1
- Also delete old perl scripts which are not used since 8+ years ago. fix #23251 fix #27367 ref https://github.com/neovim/neovim/issues/2252#issuecomment-1902662577 Helped-by: Daniel Kongsgaard <dakongsgaard@gmail.com> Co-authored-by: Kevin Pham <keevan.pham@gmail.com>
2024-04-28feat(defaults): visual CTRL-R for LSP mappings #28537Justin M. Keyes1
Problem: The new LSP "refactor menu" keybinding "crr" is also defined in visual mode, which overlaps with the builtin "c". Solution: Use CTRL-R instead of "crr" for visual mode. fix #28528
2024-04-28feat(defaults): improve :grep defaults #28545Luna Saphie Mittelbach1
Based on feedback from #28324, pass -H and -I to regular grep (available on all platforms officially supported by Neovim), and only pass -uu to ripgrep. This makes :grep ignore binary files by default in both cases.
2024-04-28fix(diagnostic): get border from config (#28531)glepnir1
Co-authored-by: Justin M. Keyes <justinkz@gmail.com> Co-authored-by: Gregory Anders <greg@gpanders.com>
2024-04-26feat(diagnostic): add default mappings for diagnostics (#16230)Gregory Anders1
2024-04-26feat(lsp): add more LSP defaults (#28500)Gregory Anders1
- crn for rename - crr for code actions - gr for references - <C-S> (in Insert mode) for signature help
2024-04-26fix: lua annotationsLewis Russell1
2024-04-25fix(vim.ui)!: change open() to return pcall-like values #28502Justin M. Keyes1
Problem: `vim.ui.open` unnecessarily invents a different success/failure convention. Its return type was changed in 57adf8c6e01d, so we might as well change it to have a more conventional form. Solution: Change the signature to use the `pcall` convention of `status, result`.
2024-04-16feat(defaults): use ripgrep (rg) for 'grepprg' if availableLuna Saphie Mittelbach1
2024-04-15fix(vim.ui): open() may wait indefinitely #28325Justin M. Keyes1
Problem: vim.ui.open "locks up" Nvim if the spawned process does not terminate. #27986 Solution: - Change `vim.ui.open()`: - Do not call `wait()`. - Return a `SystemObj`. The caller can decide if it wants to `wait()`. - Change `gx` to `wait()` only a short time. - Allows `gx` to show a message if the command fails, without the risk of waiting forever.
2024-04-15fix(defaults): only repeat macro for each selected line if linewise (#28289)zeertzjq1
As mentioned in #28287, repeating a macro for each selected line doesn't really make sense in non-linewise Visual mode. Fix #28287
2024-04-13fix(defaults): auto-close terminal for &shell with args (#28276)Jaehwang Jung1
Problem: The `:terminal` auto-close logic does not support `&shell` that has arguments, e.g., `/bin/bash -O globstar`. Solution: Join `argv` and match `&shell`. This is not perfect since `&shell` may contain irregular spaces and quotes, but it seems to be good enough.
2024-04-12test: macros in Visual mode without default mappings (#28288)zeertzjq1
2024-04-05feat(comment): add built-in commentingEvgeni Chasnovski1
Design - Enable commenting support only through `gc` mappings for simplicity. No ability to configure, no Lua module, no user commands. Yet. - Overall implementation is a simplified version of 'mini.comment' module of 'echasnovski/mini.nvim' adapted to be a better suit for core. It basically means reducing code paths which use only specific fixed set of plugin config. All used options are default except `pad_comment_parts = false`. This means that 'commentstring' option is used as is without forcing single space inner padding. As 'tpope/vim-commentary' was considered for inclusion earlier, here is a quick summary of how this commit differs from it: - **User-facing features**. Both implement similar user-facing mappings. This commit does not include `gcu` which is essentially a `gcgc`. There are no commands, events, or configuration in this commit. - **Size**. Both have reasonably comparable number of lines of code, while this commit has more comments in tricky areas. - **Maintainability**. This commit has (purely subjectively) better readability, tests, and Lua types. - **Configurability**. This commit has no user configuration, while 'vim-commentary' has some (partially as a counter-measure to possibly modifying 'commentstring' option). - **Extra features**: - This commit supports tree-sitter by computing `'commentstring'` option under cursor, which can matter in presence of tree-sitter injected languages. - This commit comments blank lines while 'tpope/vim-commentary' does not. At the same time, blank lines are not taken into account when deciding the toggle action. - This commit has much better speed on larger chunks of lines (like above 1000). This is thanks to using `nvim_buf_set_lines()` to set all new lines at once, and not with `vim.fn.setline()`.
2024-04-05feat(defaults): add :Inspect to right-click menu (#28181)zeertzjq1
Ref #21393 - Move default user commands to _defaults.lua as that now contains all kinds of defaults rather than just default mappings and menus. - Remove the :aunmenu as there are no menus when _defaults.lua is run.
2024-03-28feat(tui): query extended underline support using DECRQSS (#28052)zeertzjq1
2024-02-29refactor(defaults): use getregion() for Visual mode gx (#27663)zeertzjq1
Also make it work better on a multiline selection.
2024-02-29vim-patch:9.1.0142: getregion() can be improved (#27662)zeertzjq1
Problem: getregion() can be improved (after v9.1.120) Solution: change getregion() implementation to use pos as lists and one optional {opt} dictionary (Shougo Matsushita) Note: The following is a breaking change! Currently, the getregion() function (included as of patch v9.1.120) takes 3 arguments: the first 2 arguments are strings, describing a position, arg3 is the type string. However, that is slightly inflexible, there is no way to specify additional arguments. So let's instead change the function signature to: getregion(pos1, pos2 [, {Dict}]) where both pos1 and pos2 are lists. This is slightly cleaner, and gives us the flexibility to specify additional arguments as key/value pairs to the optional Dict arg. Now it supports the "type" key to specify the selection type (characterwise, blockwise or linewise) and now in addition one can also define the selection type, independently of what the 'selection' option actually is. Technically, this is a breaking change, but since the getregion() Vimscript function is still quite new, this should be fine. closes: vim/vim#14090 https://github.com/vim/vim/commit/19b718828d8d5fab52d94c6cdba694641879ab38 Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
2024-02-26fix(defaults): validate 'channel' before responding to OSC request (#27594)Gregory Anders1
Validate the channel number before responding to an OSC 10/11 request. When used with nvim_open_term, the channel number is unset (since there is no process on the other side of the PTY).
2024-02-23refactor(defaults): use getregion() for default * and # mappingszeertzjq1
2024-02-22fix(defaults): make terminal autoclose not block other events (#27581)Evgeni Chasnovski1
Problem: When terminal is autocloses, it blocks other events, like `BufEnter`. Solution: Use `nested = true`.
2024-02-22fix(defaults): remove tmux background detection passthrough (#27571)zeertzjq1
There is now a new tmux 3.4 release that queries background color from the parent terminal if background is not set in tmux, so removing the passthrough still works when background is not set in tmux, and fixes the incorrect detection when background is set in tmux.
2024-01-15feat(terminal): respond to OSC background and foreground request (#17197)Daniel Steinberg1
The motivation for this update is Issue #15365, where background=light is not properly set for Nvim running from an Nvim :terminal. This can be encountered when e.g., opening a terminal to make git commits, which opens EDITOR=nvim in the nested terminal. Under the implementation of this commit, the OSC response always indicates a black or white foreground/background. While this may not reflect the actual foreground/background color, it permits 'background' to be retained for a nested Nvim instance running in the terminal emulator. The behaviour matches Vim.
2024-01-06fix(defaults): use augroup for default autocommands (#26933)Gregory Anders1
2023-12-28docs: small fixes (#26651)dundargoc1
Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: WillLillis <wlillis@umass.edu>
2023-12-27feat(defaults): map Q and @x to repeat in Visual mode (#26495)Nacho Nieva1
2023-12-15refactor(defaults): always set options, even if value hasn't changed (#26595)Gregory Anders1
Comparing against the old value before setting matched the original C implementation, but there is no reason to use this restriction. In particular, this inhibits using OptionSet to determine when the option was set. If users need to handle a case where the option _changed_, it is easy to do so in an OptionSet autocommand using v:option_new and v:option_old (and friends).
2023-12-14refactor(defaults): defer setting 'termguicolors' until after VimEnterGregory Anders1
This ensures that any OptionSet autocommands will fire when the value is changed.
2023-12-14docs: add comment for OSC 11 tmux passthrough (#26566)Gregory Anders1
2023-12-14fix(defaults): background detection in tmux (#26557)Jaehwang Jung1
Wrap the query with passthrough sequence
2023-12-06feat(defaults): enable 'termguicolors' by default when supported by terminalGregory Anders1
Enable 'termguicolors' automatically when Nvim can detect that truecolor is supported by the host terminal. If $COLORTERM is set to "truecolor" or "24bit", or the terminal's terminfo entry contains capabilities for Tc, RGB, or setrgbf and setrgbb, then we assume that the terminal supports truecolor. Otherwise, the terminal is queried (using both XTGETTCAP and SGR + DECRQSS). If the terminal's response to these queries (if any) indicates that it supports truecolor, then 'termguicolors' is enabled.
2023-11-30fix: use BEL to terminate OSC 11 request (#26335)Gregory Anders1
2023-11-29fix(defaults): wait until VimEnter to set background (#26284)Gregory Anders1
The OptionSet autocommand does not fire until Vim has finished starting, so setting 'background' before the VimEnter event would not fire the OptionSet event. The prior implementation also waited until VimEnter to set 'background', so this was a regression introduced when moving background detection into Lua.
2023-11-16refactor: use optional base argument of tonumber (#26070)Gregory Anders1