mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	refactor(terminal): move :terminal defaults to _defaults.lua
This commit is contained in:
		| @@ -140,6 +140,8 @@ TERMINAL | |||||||
|  |  | ||||||
| • The |terminal| now understands the OSC 52 escape sequence to write to the | • The |terminal| now understands the OSC 52 escape sequence to write to the | ||||||
|   system clipboard (copy). Querying with OSC 52 (paste) is not supported. |   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 | TREESITTER | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5111,7 +5111,7 @@ StatusLineNC	Status lines of not-current windows. | |||||||
| StatusLineTerm	Status line of |terminal| window. | StatusLineTerm	Status line of |terminal| window. | ||||||
| 							*hl-StatusLineTermNC* | 							*hl-StatusLineTermNC* | ||||||
| StatusLineTermNC | StatusLineTermNC | ||||||
| 		Status line of non-current |terminal| window. | 		Status line of non-current |terminal| windows. | ||||||
| 							*hl-TabLine* | 							*hl-TabLine* | ||||||
| TabLine		Tab pages line, not active tab page label. | TabLine		Tab pages line, not active tab page label. | ||||||
| 							*hl-TabLineFill* | 							*hl-TabLineFill* | ||||||
|   | |||||||
| @@ -166,6 +166,14 @@ nvim_terminal: | |||||||
|   when 'background' is "light". While this may not reflect the actual |   when 'background' is "light". While this may not reflect the actual | ||||||
|   foreground/background color, it permits 'background' to be retained for a |   foreground/background color, it permits 'background' to be retained for a | ||||||
|   nested Nvim instance running in the terminal emulator. |   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: | nvim_cmdwin: | ||||||
| - CmdwinEnter: Limits syntax sync to maxlines=1 in the |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. | - Highlight groups names are allowed to contain `@` characters. | ||||||
|   - It is an error to define a highlight group with a name that doesn't match |   - 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|). |     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: | Macro (|recording|) behavior: | ||||||
| - Replay of a macro recorded during :lmap produces the same actions as when it | - Replay of a macro recorded during :lmap produces the same actions as when it | ||||||
| @@ -665,17 +675,6 @@ Events: | |||||||
| - *SafeStateAgain* | - *SafeStateAgain* | ||||||
| - *SigUSR1* Use |Signal| to detect `SIGUSR1` signal instead. | - *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: | Options: | ||||||
| - *'aleph'* *'al'* | - *'aleph'* *'al'* | ||||||
| - antialias | - antialias | ||||||
|   | |||||||
| @@ -282,6 +282,26 @@ do | |||||||
|     end, |     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', { |   vim.api.nvim_create_autocmd('CmdwinEnter', { | ||||||
|     pattern = '[:>]', |     pattern = '[:>]', | ||||||
|     desc = 'Limit syntax sync to maxlines=1 in the command window', |     desc = 'Limit syntax sync to maxlines=1 in the command window', | ||||||
|   | |||||||
| @@ -343,14 +343,6 @@ void terminal_open(Terminal **termpp, buf_T *buf, TerminalOptions opts) | |||||||
|   refresh_screen(term, buf); |   refresh_screen(term, buf); | ||||||
|   set_option_value(kOptBuftype, STATIC_CSTR_AS_OPTVAL("terminal"), OPT_LOCAL); |   set_option_value(kOptBuftype, STATIC_CSTR_AS_OPTVAL("terminal"), OPT_LOCAL); | ||||||
|  |  | ||||||
|   // Default settings for terminal buffers |  | ||||||
|   buf->b_p_ma = false;     // 'nomodifiable' |  | ||||||
|   buf->b_p_ul = -1;        // 'undolevels' |  | ||||||
|   buf->b_p_scbk =          // 'scrollback' (initialize local from global) |  | ||||||
|                   (p_scbk < 0) ? 10000 : MAX(1, p_scbk); |  | ||||||
|   buf->b_p_tw = 0;         // 'textwidth' |  | ||||||
|   set_option_value(kOptWrap, BOOLEAN_OPTVAL(false), OPT_LOCAL); |  | ||||||
|   set_option_value(kOptList, BOOLEAN_OPTVAL(false), OPT_LOCAL); |  | ||||||
|   if (buf->b_ffname != NULL) { |   if (buf->b_ffname != NULL) { | ||||||
|     buf_set_term_title(buf, buf->b_ffname, strlen(buf->b_ffname)); |     buf_set_term_title(buf, buf->b_ffname, strlen(buf->b_ffname)); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -196,10 +196,10 @@ describe(':terminal buffer', function() | |||||||
|     screen:expect([[ |     screen:expect([[ | ||||||
|       ab^c                                               | |       ab^c                                               | | ||||||
|       {4:~                                                 }| |       {4:~                                                 }| | ||||||
|       {5:==========                                        }| |       {17:==========                                        }| | ||||||
|       rows: 2, cols: 50                                 | |       rows: 2, cols: 50                                 | | ||||||
|       {2: }                                                 | |       {2: }                                                 | | ||||||
|       {1:==========                                        }| |       {18:==========                                        }| | ||||||
|                                                         | |                                                         | | ||||||
|     ]]) |     ]]) | ||||||
|  |  | ||||||
| @@ -340,7 +340,7 @@ describe(':terminal buffer', function() | |||||||
|     eq(termbuf, eval('g:termbuf')) |     eq(termbuf, eval('g:termbuf')) | ||||||
|   end) |   end) | ||||||
|  |  | ||||||
|   it('TermReqeust synchronization #27572', function() |   it('TermRequest synchronization #27572', function() | ||||||
|     command('autocmd! nvim_terminal TermRequest') |     command('autocmd! nvim_terminal TermRequest') | ||||||
|     local term = exec_lua([[ |     local term = exec_lua([[ | ||||||
|       _G.input = {} |       _G.input = {} | ||||||
|   | |||||||
| @@ -14,10 +14,12 @@ describe(':terminal mouse', function() | |||||||
|   before_each(function() |   before_each(function() | ||||||
|     clear() |     clear() | ||||||
|     api.nvim_set_option_value('statusline', '==========', {}) |     api.nvim_set_option_value('statusline', '==========', {}) | ||||||
|     command('highlight StatusLine cterm=NONE') |  | ||||||
|     command('highlight StatusLineNC cterm=NONE') |  | ||||||
|     command('highlight VertSplit cterm=NONE') |  | ||||||
|     screen = tt.screen_setup() |     screen = tt.screen_setup() | ||||||
|  |     command('highlight StatusLine NONE') | ||||||
|  |     command('highlight StatusLineNC NONE') | ||||||
|  |     command('highlight StatusLineTerm NONE') | ||||||
|  |     command('highlight StatusLineTermNC NONE') | ||||||
|  |     command('highlight VertSplit NONE') | ||||||
|     local lines = {} |     local lines = {} | ||||||
|     for i = 1, 30 do |     for i = 1, 30 do | ||||||
|       table.insert(lines, 'line' .. tostring(i)) |       table.insert(lines, 'line' .. tostring(i)) | ||||||
|   | |||||||
| @@ -92,6 +92,8 @@ local function screen_setup(extra_rows, command, cols, env, screen_opts) | |||||||
|  |  | ||||||
|   api.nvim_command('highlight TermCursor cterm=reverse') |   api.nvim_command('highlight TermCursor cterm=reverse') | ||||||
|   api.nvim_command('highlight TermCursorNC ctermbg=11') |   api.nvim_command('highlight TermCursorNC ctermbg=11') | ||||||
|  |   api.nvim_command('highlight StatusLineTerm ctermbg=2 ctermfg=0') | ||||||
|  |   api.nvim_command('highlight StatusLineTermNC ctermbg=2 ctermfg=8') | ||||||
|  |  | ||||||
|   local screen = Screen.new(cols, 7 + extra_rows) |   local screen = Screen.new(cols, 7 + extra_rows) | ||||||
|   screen:set_default_attr_ids({ |   screen:set_default_attr_ids({ | ||||||
| @@ -111,6 +113,8 @@ local function screen_setup(extra_rows, command, cols, env, screen_opts) | |||||||
|     [14] = { underline = true, reverse = true, bold = true }, |     [14] = { underline = true, reverse = true, bold = true }, | ||||||
|     [15] = { underline = true, foreground = 12 }, |     [15] = { underline = true, foreground = 12 }, | ||||||
|     [16] = { background = 248, foreground = 0 }, -- Visual in :terminal session |     [16] = { background = 248, foreground = 0 }, -- Visual in :terminal session | ||||||
|  |     [17] = { background = 2, foreground = 0 }, -- StatusLineTerm | ||||||
|  |     [18] = { background = 2, foreground = 8 }, -- StatusLineTermNC | ||||||
|   }) |   }) | ||||||
|  |  | ||||||
|   screen:attach(screen_opts or { rgb = false }) |   screen:attach(screen_opts or { rgb = false }) | ||||||
|   | |||||||
| @@ -22,10 +22,12 @@ describe(':terminal', function() | |||||||
|     -- set the statusline to a constant value because of variables like pid |     -- set the statusline to a constant value because of variables like pid | ||||||
|     -- and current directory and to improve visibility of splits |     -- and current directory and to improve visibility of splits | ||||||
|     api.nvim_set_option_value('statusline', '==========', {}) |     api.nvim_set_option_value('statusline', '==========', {}) | ||||||
|     command('highlight StatusLine cterm=NONE') |  | ||||||
|     command('highlight StatusLineNC cterm=NONE') |  | ||||||
|     command('highlight VertSplit cterm=NONE') |  | ||||||
|     screen = tt.screen_setup(3) |     screen = tt.screen_setup(3) | ||||||
|  |     command('highlight StatusLine NONE') | ||||||
|  |     command('highlight StatusLineNC NONE') | ||||||
|  |     command('highlight StatusLineTerm NONE') | ||||||
|  |     command('highlight StatusLineTermNC NONE') | ||||||
|  |     command('highlight VertSplit NONE') | ||||||
|   end) |   end) | ||||||
|  |  | ||||||
|   after_each(function() |   after_each(function() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Gregory Anders
					Gregory Anders