aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2024-06-12 11:17:53 -0500
committerGitHub <noreply@github.com>2024-06-12 11:17:53 -0500
commit9cac40ba1e1e973392e4db71d2855867b57ce850 (patch)
tree90ac84e59533ad03c8a9199d52a5562c028b0db3 /runtime
parent72155121006bca884e154e935640054f2e090367 (diff)
parentd38912b59f97a4da0a2d0a24af226e6dd27e9b2c (diff)
downloadrneovim-9cac40ba1e1e973392e4db71d2855867b57ce850.tar.gz
rneovim-9cac40ba1e1e973392e4db71d2855867b57ce850.tar.bz2
rneovim-9cac40ba1e1e973392e4db71d2855867b57ce850.zip
Merge pull request #29290 from gpanders/push-wuqlkrkuypzz
Add StatusLineTerm highlight group and move terminal buffer defaults
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/news.txt2
-rw-r--r--runtime/doc/syntax.txt5
-rw-r--r--runtime/doc/vim_diff.txt21
-rw-r--r--runtime/lua/vim/_defaults.lua20
4 files changed, 37 insertions, 11 deletions
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 455b38b5fa..4addbf84c3 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -140,6 +140,8 @@ TERMINAL
• The |terminal| now understands the OSC 52 escape sequence to write to the
system clipboard (copy). Querying with OSC 52 (paste) is not supported.
+• |hl-StatusLineTerm| and |hl-StatusLineTermNC| define highlights for the
+ status line in |terminal| windows.
TREESITTER
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index 8e38827e87..9fc415a158 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -5107,6 +5107,11 @@ SpellRare Word that is recognized by the spellchecker as one that is
StatusLine Status line of current window.
*hl-StatusLineNC*
StatusLineNC Status lines of not-current windows.
+ *hl-StatusLineTerm*
+StatusLineTerm Status line of |terminal| window.
+ *hl-StatusLineTermNC*
+StatusLineTermNC
+ Status line of non-current |terminal| windows.
*hl-TabLine*
TabLine Tab pages line, not active tab page label.
*hl-TabLineFill*
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index ac20948f14..a6f08402f6 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -166,6 +166,14 @@ nvim_terminal:
when 'background' is "light". 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.
+- TermOpen: Sets default options for |terminal| buffers:
+ - 'nomodifiable'
+ - 'undolevels' set to -1
+ - 'textwidth' set to 0
+ - 'nowrap'
+ - 'nolist'
+ - 'winhighlight' uses |hl-StatusLineTerm| and |hl-StatusLineTermNC| in
+ place of |hl-StatusLine| and |hl-StatusLineNC|
nvim_cmdwin:
- CmdwinEnter: Limits syntax sync to maxlines=1 in the |cmdwin|.
@@ -538,6 +546,8 @@ Highlight groups:
- Highlight groups names are allowed to contain `@` characters.
- It is an error to define a highlight group with a name that doesn't match
the regexp `[a-zA-Z0-9_.@-]*` (see |group-name|).
+- |hl-StatusLineTerm| |hl-StatusLineTermNC| are implemented as 'winhighlight'
+ window-local highlights which are set by the default |TermOpen| handler.
Macro (|recording|) behavior:
- Replay of a macro recorded during :lmap produces the same actions as when it
@@ -665,17 +675,6 @@ Events:
- *SafeStateAgain*
- *SigUSR1* Use |Signal| to detect `SIGUSR1` signal instead.
-Highlight groups:
-- *hl-StatusLineTerm* *hl-StatusLineTermNC* are unnecessary because Nvim
- supports 'winhighlight' window-local highlights. For example, to mimic Vim's
- StatusLineTerm: >vim
- hi StatusLineTerm ctermfg=black ctermbg=green
- hi StatusLineTermNC ctermfg=green
- autocmd TermOpen,WinEnter * if &buftype=='terminal'
- \|setlocal winhighlight=StatusLine:StatusLineTerm,StatusLineNC:StatusLineTermNC
- \|else|setlocal winhighlight=|endif
-<
-
Options:
- *'aleph'* *'al'*
- antialias
diff --git a/runtime/lua/vim/_defaults.lua b/runtime/lua/vim/_defaults.lua
index 01dcd4bf74..f417bda3fb 100644
--- a/runtime/lua/vim/_defaults.lua
+++ b/runtime/lua/vim/_defaults.lua
@@ -282,6 +282,26 @@ do
end,
})
+ vim.api.nvim_create_autocmd('TermOpen', {
+ group = nvim_terminal_augroup,
+ desc = 'Default settings for :terminal buffers',
+ callback = function()
+ vim.bo.modifiable = false
+ vim.bo.undolevels = -1
+ vim.bo.scrollback = vim.o.scrollback < 0 and 10000 or math.max(1, vim.o.scrollback)
+ vim.bo.textwidth = 0
+ vim.wo.wrap = false
+ vim.wo.list = false
+
+ -- This is gross. Proper list options support when?
+ local winhl = vim.o.winhighlight
+ if winhl ~= '' then
+ winhl = winhl .. ','
+ end
+ vim.wo.winhighlight = winhl .. 'StatusLine:StatusLineTerm,StatusLineNC:StatusLineTermNC'
+ end,
+ })
+
vim.api.nvim_create_autocmd('CmdwinEnter', {
pattern = '[:>]',
desc = 'Limit syntax sync to maxlines=1 in the command window',