Compare commits

...

10 Commits

Author SHA1 Message Date
Tim Pope 18d50bb6ec
Merge 4541189052 into 435dee74bb 2024-04-27 11:30:49 +08:00
zeertzjq 435dee74bb
vim-patch:9.1.0374: wrong botline in BufEnter (#28530)
Problem:  When :edit an existing buffer, line('w$') may return a
          wrong result.
Solution: Reset w_valid in curwin_init() (Jaehwang Jung)

`do_ecmd()` reinitializes the current window (`curwin_init()`) whose
`w_valid` field may have `VALID_BOTLINE` set. Resetting `w_botline`
without marking it as invalid makes subsequent `validate_botline()`
calls a no-op, thus resulting in wrong `line('w$')` value.

closes: vim/vim#14642

eb80b8304e

Co-authored-by: Jaehwang Jung <tomtomjhj@gmail.com>
2024-04-27 06:32:25 +08:00
zeertzjq 694756252b
Merge pull request #28529 from zeertzjq/vim-fe1e2b5e2d65
vim-patch: clarify syntax vs matching mechanism
2024-04-27 06:31:55 +08:00
zeertzjq e81eb34aa1 vim-patch:9525f6213604
runtime(doc): fix typo synconcealend -> synconcealed (vim/vim#14644)

9525f62136

Co-authored-by: Philip H <47042125+pheiduck@users.noreply.github.com>
2024-04-27 05:52:47 +08:00
zeertzjq a1568f5df0 vim-patch:00ae5c5cba7b
runtime(doc): fix typo

00ae5c5cba

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-04-27 05:52:15 +08:00
zeertzjq f1f5fb911b vim-patch:fe1e2b5e2d65
runtime(doc): clarify syntax vs matching mechanism

fixes: vim/vim#14643

fe1e2b5e2d

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-04-27 05:51:52 +08:00
Mathias Fußenegger 9b8a075539
fix(lsp): change `silent` in lsp.start.Opts to optional (#28524) 2024-04-26 20:26:21 +02:00
Gregory Anders 73034611c2
feat(diagnostic): add default mappings for diagnostics (#16230) 2024-04-26 13:16:12 -05:00
Brian Cao 3a7c30dc93
fix(man.vim): q quits after jump to different tag in MANPAGER modified (#28495) 2024-04-26 13:14:45 -05:00
Tim Pope 4541189052 fix(lsp): support workspace/configuation with no section 2024-02-17 17:53:49 -05:00
21 changed files with 120 additions and 16 deletions

View File

@ -8208,6 +8208,10 @@ synconcealed({lnum}, {col}) *synconcealed()*
synconcealed(lnum, 5) [1, 'X', 2]
synconcealed(lnum, 6) [0, '', 0]
Note: Doesn't consider |matchadd()| highlighting items,
since syntax and matching highlighting are two different
mechanisms |syntax-vs-match|.
synstack({lnum}, {col}) *synstack()*
Return a |List|, which is the stack of syntax items at the
position {lnum} and {col} in the current window. {lnum} is

View File

@ -869,7 +869,7 @@ start({config}, {opts}) *vim.lsp.start()*
re-uses a client if name and root_dir matches.
• {bufnr} (`integer`) Buffer handle to attach to if starting
or re-using a client (0 for current).
• {silent} (`boolean`) Suppress error reporting if the LSP
• {silent}? (`boolean`) Suppress error reporting if the LSP
server fails to start (default false).
Return: ~

View File

@ -412,6 +412,10 @@ The following changes to existing APIs or features add new behavior.
• |crr| in Normal and Visual mode maps to |vim.lsp.buf.code_action()|.
• "gr" in Normal mode maps to |vim.lsp.buf.references()| |gr-default|
• |i_CTRL-S| in Insert mode maps to |vim.lsp.buf.signature_help()|
• "]d" and "[d" in Normal mode map to |vim.diagnostic.goto_next()| and
|vim.diagnostic.goto_prev()|, respectively. |]d-default| |[d-default|
• <C-W>d (and <C-W><C-D>) map to |vim.diagnostic.open_float()|
|CTRL-W_d-default|
• Automatic linting of treesitter query files (see |ft-query-plugin|).
Can be disabled via: >lua
vim.g.query_lint_on = {}

View File

@ -1375,6 +1375,19 @@ Finally, these constructs are unique to Perl:
==============================================================================
10. Highlighting matches *match-highlight*
*syntax-vs-match*
Note that the match highlight mechanism is independent
of |syntax-highlighting|, which is (usually) a buffer-local
highlighting, while matching is window-local, both methods
can be freely mixed. Match highlighting functions give you
a bit more flexibility in when and how to apply, but are
typically only used for temporary highlighting, without strict
rules. Both methods can be used to conceal text.
Thus the matching functions like |matchadd()| won't consider
syntax rules and functions like |synconcealed()| and the
other way around.
*:mat* *:match*
:mat[ch] {group} /{pattern}/
Define a pattern to highlight in the current window. It will

View File

@ -3825,7 +3825,9 @@ Whether or not it is actually concealed depends on the value of the
'conceallevel' option. The 'concealcursor' option is used to decide whether
concealable items in the current line are displayed unconcealed to be able to
edit the line.
Another way to conceal text is with |matchadd()|.
Another way to conceal text is with |matchadd()|, but internally this works a
bit differently |syntax-vs-match|.
concealends *:syn-concealends*
@ -3833,7 +3835,9 @@ When the "concealends" argument is given, the start and end matches of
the region, but not the contents of the region, are marked as concealable.
Whether or not they are actually concealed depends on the setting on the
'conceallevel' option. The ends of a region can only be concealed separately
in this way when they have their own highlighting via "matchgroup"
in this way when they have their own highlighting via "matchgroup". The
|synconcealed()| function can be used to retrieve information about conealed
items.
cchar *:syn-cchar*
*E844*

View File

@ -780,9 +780,17 @@ CTRL-W i Open a new window, with the cursor on the first line
beginning of the file. If a count is given, the
count'th matching line is displayed.
*[d-default*
Mapped to |vim.diagnostic.goto_prev()| by default.
|default-mappings|
*]d*
]d like "[d", but start at the current cursor position.
*]d-default*
Mapped to |vim.diagnostic.goto_next()| by default.
|default-mappings|
*:ds* *:dsearch*
:[range]ds[earch][!] [count] [/]string[/]
Like "[d" and "]d", but search in [range] lines
@ -829,6 +837,10 @@ CTRL-W d Open a new window, with the cursor on the first
beginning of the file. If a count is given, the
count'th matching line is jumped to.
*CTRL-W_d-default*
Mapped to |vim.diagnostic.open_float()| by default.
|default-mappings|
*:dsp* *:dsplit*
:[range]dsp[lit][!] [count] [/]string[/]
Like "CTRL-W d", but search in [range] lines

View File

@ -948,7 +948,7 @@ Syntax and highlighting: *syntax-functions* *highlighting-functions*
synIDattr() get a specific attribute of a syntax ID
synIDtrans() get translated syntax ID
synstack() get list of syntax IDs at a specific position
synconcealed() get info about concealing
synconcealed() get info about (syntax) concealing
diff_hlID() get highlight ID for diff mode at a position
matchadd() define a pattern to highlight (a "match")
matchaddpos() define a list of positions to highlight

View File

@ -141,6 +141,9 @@ of these in your config by simply removing the mapping, e.g. ":unmap Y".
- |crr|
- gr |gr-default|
- <C-S> |i_CTRL-S|
- ]d |]d-default|
- [d |[d-default|
- <C-W>d |CTRL-W_d-default|
- Nvim LSP client defaults |lsp-defaults|
- K |K-lsp-default|

View File

@ -24,7 +24,7 @@ if !exists('g:no_plugin_maps') && !exists('g:no_man_maps')
nnoremap <silent> <buffer> k gk
nnoremap <silent> <buffer> gO :lua require'man'.show_toc()<CR>
nnoremap <silent> <buffer> <2-LeftMouse> :Man<CR>
if get(b:, 'pager')
if get(g:, 'pager')
nnoremap <silent> <buffer> <nowait> q :lclose<CR><C-W>q
else
nnoremap <silent> <buffer> <nowait> q :lclose<CR><C-W>c

View File

@ -411,15 +411,13 @@ local function find_man()
return false
end
---@param pager boolean
local function set_options(pager)
local function set_options()
vim.bo.swapfile = false
vim.bo.buftype = 'nofile'
vim.bo.bufhidden = 'unload'
vim.bo.modified = false
vim.bo.readonly = true
vim.bo.modifiable = false
vim.b.pager = pager
vim.bo.filetype = 'man'
end
@ -475,7 +473,7 @@ local function put_page(page)
vim.cmd([[silent! keeppatterns keepjumps %s/\s\{199,}/\=repeat(' ', 10)/g]])
vim.cmd('1') -- Move cursor to first line
highlight_man_page()
set_options(false)
set_options()
end
local function format_candidate(path, psect)
@ -662,7 +660,8 @@ function M.init_pager()
vim.cmd.file({ 'man://' .. fn.fnameescape(ref):lower(), mods = { silent = true } })
end
set_options(true)
vim.g.pager = true
set_options()
end
---@param count integer
@ -730,7 +729,7 @@ function M.open_page(count, smods, args)
if not ok then
error(ret)
else
set_options(false)
set_options()
end
vim.b.man_sect = sect

View File

@ -127,7 +127,9 @@ do
end, { desc = gx_desc })
end
--- Default maps for built-in commenting
--- Default maps for built-in commenting.
---
--- See |gc-default| and |gcc-default|.
do
local operator_rhs = function()
return require('vim._comment').operator()
@ -169,6 +171,35 @@ do
vim.lsp.buf.signature_help()
end, { desc = 'vim.lsp.buf.signature_help()' })
end
--- Map [d and ]d to move to the previous/next diagnostic. Map <C-W>d to open a floating window
--- for the diagnostic under the cursor.
---
--- See |[d-default|, |]d-default|, and |CTRL-W_d-default|.
do
vim.keymap.set('n', ']d', function()
vim.diagnostic.goto_next({ float = false })
end, {
desc = 'Jump to the next diagnostic with the highest severity',
})
vim.keymap.set('n', '[d', function()
vim.diagnostic.goto_prev({ float = false })
end, {
desc = 'Jump to the previous diagnostic with the highest severity',
})
vim.keymap.set('n', '<C-W>d', function()
vim.diagnostic.open_float({ border = 'rounded' })
end, {
desc = 'Open a floating window showing diagnostics under the cursor',
})
vim.keymap.set('n', '<C-W><C-D>', '<C-W>d', {
remap = true,
desc = 'Open a floating window showing diagnostics under the cursor',
})
end
end
--- Default menus

View File

@ -9752,6 +9752,10 @@ function vim.fn.synIDtrans(synID) end
--- synconcealed(lnum, 5) [1, 'X', 2]
--- synconcealed(lnum, 6) [0, '', 0]
---
--- Note: Doesn't consider |matchadd()| highlighting items,
--- since syntax and matching highlighting are two different
--- mechanisms |syntax-vs-match|.
---
--- @param lnum integer
--- @param col integer
--- @return {[1]: integer, [2]: string, [3]: integer}

View File

@ -201,7 +201,7 @@ end
--- @field bufnr integer
---
--- Suppress error reporting if the LSP server fails to start (default false).
--- @field silent boolean
--- @field silent? boolean
--- Create a new LSP client and start a language server or reuses an already
--- running client if one is found matching `name` and `root_dir`.

View File

@ -209,6 +209,9 @@ M[ms.workspace_configuration] = function(_, result, ctx)
value = vim.NIL
end
table.insert(response, value)
else
-- If no section is provided, return settings as is
table.insert(response, client.settings)
end
end
return response

View File

@ -47,8 +47,8 @@ typedef struct {
#define VALID_VIRTCOL 0x04 // w_virtcol (file col) is valid
#define VALID_CHEIGHT 0x08 // w_cline_height and w_cline_folded valid
#define VALID_CROW 0x10 // w_cline_row is valid
#define VALID_BOTLINE 0x20 // w_botine and w_empty_rows are valid
#define VALID_BOTLINE_AP 0x40 // w_botine is approximated
#define VALID_BOTLINE 0x20 // w_botline and w_empty_rows are valid
#define VALID_BOTLINE_AP 0x40 // w_botline is approximated
#define VALID_TOPLINE 0x80 // w_topline is valid (for cursor position)
// flags for b_flags

View File

@ -11621,6 +11621,10 @@ M.funcs = {
synconcealed(lnum, 4) [1, 'X', 2]
synconcealed(lnum, 5) [1, 'X', 2]
synconcealed(lnum, 6) [0, '', 0]
Note: Doesn't consider |matchadd()| highlighting items,
since syntax and matching highlighting are two different
mechanisms |syntax-vs-match|.
]=],
name = 'synconcealed',
params = { { 'lnum', 'integer' }, { 'col', 'integer' } },

View File

@ -2467,6 +2467,7 @@ void win_init_empty(win_T *wp)
wp->w_topline = 1;
wp->w_topfill = 0;
wp->w_botline = 2;
wp->w_valid = 0;
wp->w_s = &wp->w_buffer->b_s;
}

View File

@ -150,9 +150,16 @@ function tests.check_workspace_configuration()
{ section = 'testSetting2' },
{ section = 'test.Setting3' },
{ section = 'test.Setting4' },
{},
{ section = '' },
},
})
expect_notification('workspace/configuration', { true, false, 'nested', vim.NIL })
local all = {
testSetting1 = true,
testSetting2 = false,
test = { Setting3 = 'nested' },
}
expect_notification('workspace/configuration', { true, false, 'nested', vim.NIL, all, all })
notify('shutdown')
end,
}

View File

@ -504,6 +504,8 @@ describe('LSP', function()
{ section = 'testSetting2' },
{ section = 'test.Setting3' },
{ section = 'test.Setting4' },
{},
{ section = '' },
},
},
{ method = 'workspace/configuration', client_id = 1 },

View File

@ -192,6 +192,7 @@ describe(':Man', function()
'--headless',
'+autocmd VimLeave * echo "quit works!!"',
'+Man!',
'+tag ls',
'+call nvim_input("q")',
}
matches('quit works!!', fn.system(args, { 'manpage contents' }))

View File

@ -4105,4 +4105,16 @@ func Test_SwapExists_set_other_buf_modified()
bwipe!
endfunc
func Test_BufEnter_botline()
set hidden
call writefile(range(10), 'Xxx1', 'D')
call writefile(range(20), 'Xxx2', 'D')
edit Xxx1
edit Xxx2
au BufEnter Xxx1 call assert_true(line('w$') > 1)
edit Xxx1
au! BufEnter Xxx1
set hidden&vim
endfunc
" vim: shiftwidth=2 sts=2 expandtab