diff options
-rw-r--r-- | .github/ISSUE_TEMPLATE/bug_report.yml | 2 | ||||
-rw-r--r-- | .github/ISSUE_TEMPLATE/lsp_bug_report.yml | 2 | ||||
-rw-r--r-- | runtime/doc/eval.txt | 4 | ||||
-rw-r--r-- | runtime/doc/lsp.txt | 16 | ||||
-rw-r--r-- | runtime/lua/vim/lsp.lua | 10 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/diagnostic.lua | 47 | ||||
-rw-r--r-- | src/nvim/globals.h | 2 | ||||
-rw-r--r-- | src/nvim/normal.c | 2 | ||||
-rw-r--r-- | src/nvim/state.c | 3 | ||||
-rw-r--r-- | src/nvim/testdir/test_functions.vim | 10 |
10 files changed, 73 insertions, 25 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index e5530a1511..474fce0167 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -54,7 +54,7 @@ body: - type: textarea attributes: label: "Expected behavior" + description: "A description of the behavior you expected. May optionally include logs, images, or videos." - type: textarea attributes: label: "Actual behavior" - description: "A description of the behavior you expected. May optionally include logs, images, or videos." diff --git a/.github/ISSUE_TEMPLATE/lsp_bug_report.yml b/.github/ISSUE_TEMPLATE/lsp_bug_report.yml index ff25bb0a23..ba1905329b 100644 --- a/.github/ISSUE_TEMPLATE/lsp_bug_report.yml +++ b/.github/ISSUE_TEMPLATE/lsp_bug_report.yml @@ -47,10 +47,10 @@ body: - type: textarea attributes: label: "Expected behavior" + description: "A description of the behavior you expected. May optionally include logs, images, or videos." - type: textarea attributes: label: "Actual behavior" - description: "A description of the behavior you expected. May optionally include logs, images, or videos." - type: markdown attributes: diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index e32691dfb4..2b6e3aff29 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -6350,6 +6350,10 @@ mode([expr]) Return a string that indicates the current mode. s Select by character S Select by line CTRL-S Select blockwise + vs Visual by character using |v_CTRL-O| from + Select mode + Vs Visual by line using |v_CTRL-O| from Select mode + CTRL-Vs Visual blockwise using |v_CTRL-O| from Select mode i Insert ic Insert mode completion |compl-generic| ix Insert mode |i_CTRL-X| completion diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index c750a65c10..7daab4d6f1 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -1487,6 +1487,22 @@ on_publish_diagnostics({_}, {_}, {params}, {client_id}, {_}, {config}) • Sort diagnostics (and thus signs and virtual text) +redraw({bufnr}, {client_id}) *vim.lsp.diagnostic.redraw()* + Redraw diagnostics for the given buffer and client + + This calls the "textDocument/publishDiagnostics" handler + manually using the cached diagnostics already received from + the server. This can be useful for redrawing diagnostics after + making changes in diagnostics configuration. + |lsp-handler-configuration| + + Parameters: ~ + {bufnr} (optional, number): Buffer handle, defaults + to current + {client_id} (optional, number): Redraw diagnostics for + the given client. The default is to redraw + diagnostics for all attached clients. + reset({client_id}, {buffer_client_map}) *vim.lsp.diagnostic.reset()* Clear diagnotics and diagnostic cache diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index f5aefc8260..87ecc3eeea 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -453,15 +453,7 @@ local function text_document_did_open_handler(bufnr, client) -- Next chance we get, we should re-do the diagnostics vim.schedule(function() - vim.lsp.handlers["textDocument/publishDiagnostics"]( - nil, - "textDocument/publishDiagnostics", - { - diagnostics = vim.lsp.diagnostic.get(bufnr, client.id), - uri = vim.uri_from_bufnr(bufnr), - }, - client.id - ) + vim.lsp.diagnostic.redraw(bufnr, client.id) end) end diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua index 246665602d..120320becc 100644 --- a/runtime/lua/vim/lsp/diagnostic.lua +++ b/runtime/lua/vim/lsp/diagnostic.lua @@ -1168,6 +1168,40 @@ function M.display(diagnostics, bufnr, client_id, config) save_extmarks(bufnr, client_id) end +--- Redraw diagnostics for the given buffer and client +--- +--- This calls the "textDocument/publishDiagnostics" handler manually using +--- the cached diagnostics already received from the server. This can be useful +--- for redrawing diagnostics after making changes in diagnostics +--- configuration. |lsp-handler-configuration| +--- +--- @param bufnr (optional, number): Buffer handle, defaults to current +--- @param client_id (optional, number): Redraw diagnostics for the given +--- client. The default is to redraw diagnostics for all attached +--- clients. +function M.redraw(bufnr, client_id) + bufnr = get_bufnr(bufnr) + if not client_id then + return vim.lsp.for_each_buffer_client(bufnr, function(client) + M.redraw(bufnr, client.id) + end) + end + + -- We need to invoke the publishDiagnostics handler directly instead of just + -- calling M.display so that we can preserve any custom configuration options + -- the user may have set with vim.lsp.with. + vim.lsp.handlers["textDocument/publishDiagnostics"]( + nil, + "textDocument/publishDiagnostics", + { + uri = vim.uri_from_bufnr(bufnr), + diagnostics = M.get(bufnr, client_id), + }, + client_id, + bufnr + ) +end + -- }}} -- Diagnostic User Functions {{{ @@ -1361,18 +1395,7 @@ function M.enable(bufnr, client_id) diagnostic_disabled[bufnr][client_id] = nil - -- We need to invoke the publishDiagnostics handler directly instead of just - -- calling M.display so that we can preserve any custom configuration options - -- the user may have set with vim.lsp.with. - vim.lsp.handlers["textDocument/publishDiagnostics"]( - nil, - "textDocument/publishDiagnostics", - { - diagnostics = M.get(bufnr, client_id), - uri = vim.uri_from_bufnr(bufnr), - }, - client_id - ) + M.redraw(bufnr, client_id) end -- }}} diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 55a912b417..7b2320effa 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -524,6 +524,8 @@ EXTERN pos_T VIsual; EXTERN int VIsual_active INIT(= false); /// Whether Select mode is active. EXTERN int VIsual_select INIT(= false); +/// Restart Select mode when next cmd finished +EXTERN int restart_VIsual_select INIT(= 0); /// Whether to restart the selection after a Select-mode mapping or menu. EXTERN int VIsual_reselect; /// Type of Visual mode. diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 4213e6f946..9185062f94 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -92,8 +92,6 @@ static linenr_T resel_VIsual_line_count; /* number of lines */ static colnr_T resel_VIsual_vcol; /* nr of cols or end col */ static int VIsual_mode_orig = NUL; /* saved Visual mode */ -static int restart_VIsual_select = 0; - #ifdef INCLUDE_GENERATED_DECLARATIONS # include "normal.c.generated.h" diff --git a/src/nvim/state.c b/src/nvim/state.c index 437cb0db47..02d63d8ab1 100644 --- a/src/nvim/state.c +++ b/src/nvim/state.c @@ -144,6 +144,9 @@ char *get_mode(void) buf[0] = (char)(VIsual_mode + 's' - 'v'); } else { buf[0] = (char)VIsual_mode; + if (restart_VIsual_select) { + buf[1] = 's'; + } } } else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE || State == CONFIRM) { diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 224ca257ab..7c00b479a3 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -534,6 +534,7 @@ func Test_mode() set complete=. inoremap <F2> <C-R>=Save_mode()<CR> + xnoremap <F2> <Cmd>call Save_mode()<CR> normal! 3G exe "normal i\<F2>\<Esc>" @@ -645,6 +646,14 @@ func Test_mode() call assert_equal("\<C-S>", mode(1)) call feedkeys("\<Esc>", 'xt') + " v_CTRL-O + exe "normal gh\<C-O>\<F2>\<Esc>" + call assert_equal("v-vs", g:current_modes) + exe "normal gH\<C-O>\<F2>\<Esc>" + call assert_equal("V-Vs", g:current_modes) + exe "normal g\<C-H>\<C-O>\<F2>\<Esc>" + call assert_equal("\<C-V>-\<C-V>s", g:current_modes) + call feedkeys(":echo \<C-R>=Save_mode()\<C-U>\<CR>", 'xt') call assert_equal('c-c', g:current_modes) call feedkeys("gQecho \<C-R>=Save_mode()\<CR>\<CR>vi\<CR>", 'xt') @@ -653,6 +662,7 @@ func Test_mode() bwipe! iunmap <F2> + xunmap <F2> set complete& endfunc |