commit kak-lsp for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package kak-lsp for openSUSE:Factory checked in at 2024-01-03 12:27:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kak-lsp (Old) and /work/SRC/openSUSE:Factory/.kak-lsp.new.28375 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "kak-lsp" Wed Jan 3 12:27:35 2024 rev:8 rq:1135973 version:15.0.1 Changes: -------- --- /work/SRC/openSUSE:Factory/kak-lsp/kak-lsp.changes 2023-11-22 18:55:16.861056742 +0100 +++ /work/SRC/openSUSE:Factory/.kak-lsp.new.28375/kak-lsp.changes 2024-01-03 12:27:41.993420423 +0100 @@ -1,0 +2,10 @@ +Mon Dec 25 09:42:34 UTC 2023 - Soc Virnyl Estela <uncomfy+openbuildservice@uncomfyhalomacro.pl> + +- Update to version 15.0.1: + * Additions: + - Default configuration for Markdown via [marksman](https://github.com/artempyanykh/marksman). + - Default configuration for Java via [jdtls](https://github.com/eclipse-jdtls/eclipse.jdt.ls). + * Fixes: + - Fix regression in "lsp-show-message-error" and friends. + +------------------------------------------------------------------- Old: ---- kak-lsp-15.0.0.tar.gz New: ---- kak-lsp-15.0.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kak-lsp.spec ++++++ --- /var/tmp/diff_new_pack.5BCh4f/_old 2024-01-03 12:27:44.713519756 +0100 +++ /var/tmp/diff_new_pack.5BCh4f/_new 2024-01-03 12:27:44.713519756 +0100 @@ -17,7 +17,7 @@ Name: kak-lsp -Version: 15.0.0 +Version: 15.0.1 Release: 0 Summary: Language Server Protocol client for Kakoune License: (Apache-2.0 OR BSL-1.0) AND (Apache-2.0 OR BSL-1.0 OR MIT) AND (Apache-2.0 OR MIT) AND (Apache-2.0 OR Apache-2.0 WITH LLVM-exception OR MIT) AND (Apache-2.0 OR MIT OR Zlib) AND (Apache-2.0 OR MIT OR MPL-2.0) AND (MIT OR Unlicense) AND (Apache-2.0 OR Zlib OR MIT) AND MIT AND Zlib AND Unlicense ++++++ kak-lsp-15.0.0.tar.gz -> kak-lsp-15.0.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kak-lsp-15.0.0/CHANGELOG.md new/kak-lsp-15.0.1/CHANGELOG.md --- old/kak-lsp-15.0.0/CHANGELOG.md 2023-11-15 09:55:21.000000000 +0100 +++ new/kak-lsp-15.0.1/CHANGELOG.md 2023-12-11 10:05:46.000000000 +0100 @@ -1,3 +1,12 @@ +## 15.0.1 - 2023-12-11 + +Additions: +- Default configuration for Markdown via [marksman](https://github.com/artempyanykh/marksman). +- Default configuration for Java via [jdtls](https://github.com/eclipse-jdtls/eclipse.jdt.ls). + +Fixes: +- Fix regression in "lsp-show-message-error" and friends. + ## 15.0.0 - 2023-11-15 Additions: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kak-lsp-15.0.0/Cargo.lock new/kak-lsp-15.0.1/Cargo.lock --- old/kak-lsp-15.0.0/Cargo.lock 2023-11-15 09:55:21.000000000 +0100 +++ new/kak-lsp-15.0.1/Cargo.lock 2023-12-11 10:05:46.000000000 +0100 @@ -546,7 +546,7 @@ [[package]] name = "kak-lsp" -version = "15.0.0" +version = "15.0.1" dependencies = [ "clap", "crossbeam-channel", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kak-lsp-15.0.0/Cargo.toml new/kak-lsp-15.0.1/Cargo.toml --- old/kak-lsp-15.0.0/Cargo.toml 2023-11-15 09:55:21.000000000 +0100 +++ new/kak-lsp-15.0.1/Cargo.toml 2023-12-11 10:05:46.000000000 +0100 @@ -1,7 +1,7 @@ [package] name = "kak-lsp" description = "Kakoune Language Server Protocol Client" -version = "15.0.0" +version = "15.0.1" authors = ["Ruslan Prokopchuk <fer.obbee@gmail.com>", "Johannes Altmanninger <aclopte@gmail.com>"] edition = "2018" license = "Unlicense/MIT" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kak-lsp-15.0.0/README.asciidoc new/kak-lsp-15.0.1/README.asciidoc --- old/kak-lsp-15.0.0/README.asciidoc 2023-11-15 09:55:21.000000000 +0100 +++ new/kak-lsp-15.0.1/README.asciidoc 2023-12-11 10:05:46.000000000 +0100 @@ -26,8 +26,8 @@ [source,sh] ---- -curl -O -L https://github.com/kak-lsp/kak-lsp/releases/download/v15.0.0/kak-lsp-v15.0.0... -tar xzvf kak-lsp-v15.0.0-x86_64-apple-darwin.tar.gz +curl -O -L https://github.com/kak-lsp/kak-lsp/releases/download/v15.0.1/kak-lsp-v15.0.1... +tar xzvf kak-lsp-v15.0.1-x86_64-apple-darwin.tar.gz # replace `~/.local/bin/` with something on your `$PATH` mv kak-lsp ~/.local/bin/ @@ -49,8 +49,8 @@ [source,sh] ---- -wget https://github.com/kak-lsp/kak-lsp/releases/download/v15.0.0/kak-lsp-v15.0.0... -tar xzvf kak-lsp-v15.0.0-x86_64-unknown-linux-musl.tar.gz +wget https://github.com/kak-lsp/kak-lsp/releases/download/v15.0.1/kak-lsp-v15.0.1... +tar xzvf kak-lsp-v15.0.1-x86_64-unknown-linux-musl.tar.gz # replace `~/.local/bin/` with something on your `$PATH` mv kak-lsp ~/.local/bin/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kak-lsp-15.0.0/ci/update-homebrew.sh new/kak-lsp-15.0.1/ci/update-homebrew.sh --- old/kak-lsp-15.0.0/ci/update-homebrew.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/kak-lsp-15.0.1/ci/update-homebrew.sh 2023-12-11 10:05:46.000000000 +0100 @@ -0,0 +1,23 @@ +#!/bin/sh + +set -ex + +tag=$(git describe) +tag=${tag%%-*} +version=${tag#v} +url=https://github.com/kak-lsp/kak-lsp/releases/download/$tag/kak-lsp-$tag-x86_6... +curl -O -L "$url" +sha=$(sha256sum "kak-lsp-$tag-x86_64-apple-darwin.tar.gz") +sha=${sha%% *} + +cd ../homebrew-kak-lsp/ +sed 4c" url \"$url\"" -i Formula/kak-lsp.rb +sed 5c" sha256 \"$sha\"" -i Formula/kak-lsp.rb +sed 6c" version \"$version\"" -i Formula/kak-lsp.rb +sed '4,6s/^/ /' -i Formula/kak-lsp.rb + +git diff +read + +git commit -am "$tag" +git push diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kak-lsp-15.0.0/kak-lsp.toml new/kak-lsp-15.0.1/kak-lsp.toml --- old/kak-lsp-15.0.0/kak-lsp.toml 2023-11-15 09:55:21.000000000 +0100 +++ new/kak-lsp-15.0.1/kak-lsp.toml 2023-12-11 10:05:46.000000000 +0100 @@ -101,35 +101,13 @@ command = "sh" args = ["-c", "dart $(dirname $(command -v dart))/snapshots/analysis_server.dart.snapshot --lsp"] -# # Commented out by default because you still need to set the paths in the JDT -# # Language Server arguments below before this can become a valid configuration. -# [language_server.ejdtls] -# filetypes = ["java"] -# roots = [".git", "mvnw", "gradlew"] -# command = "java" -# args = [ -# "-Declipse.application=org.eclipse.jdt.ls.core.id1", -# "-Dosgi.bundles.defaultStartLevel=4", -# "-Declipse.product=org.eclipse.jdt.ls.core.product", -# "-Dlog.level=ALL", -# "-Dfile.encoding=utf-8", -# "--add-modules=ALL-SYSTEM", -# "--add-opens", -# "java.base/java.util=ALL-UNNAMED", -# "--add-opens", -# "java.base/java.lang=ALL-UNNAMED", -# "-noverify", -# "-Xmx1G", -# "-jar", -# "/path/to/eclipse.jdt.ls/repository/plugins/org.eclipse.equinox.launcher_1.6.100.v20201223-0822.jar", -# "-configuration", -# "/path/to/eclipse.jdt.ls/repository/config_linux", -# "-data", -# "/path/to/eclipse-workspace", -# ] -# [language_server.ejdtls.settings] -# # See https://github.dev/eclipse/eclipse.jdt.ls -# # "java.format.insertSpaces" = true +[language_server.jdtls] +filetypes = ["java"] +roots = ["mvnw", "gradlew", ".git", ".hg"] +command = "jdtls" +[language_server.jdtls.settings] +# See https://github.dev/eclipse/eclipse.jdt.ls +# "java.format.insertSpaces" = true [language_server.elixir-ls] filetypes = ["elixir"] @@ -265,6 +243,12 @@ # See https://github.com/sumneko/vscode-lua/blob/master/setting/schema.json # diagnostics.enable = true +[language_server.markdown] +filetypes = ["markdown"] +roots = [".marksman.toml"] +command = "marksman" +args = ["server"] + [language_server.nimlsp] filetypes = ["nim"] roots = ["*.nimble", ".git", ".hg"] @@ -303,6 +287,15 @@ # command = "pyright-langserver" # args = ["--stdio"] +# [language_server.ruff] +# filetypes = ["python"] +# roots = ["requirements.txt", "setup.py", ".git", ".hg"] +# command = "ruff-lsp" +# settings_section = "_" +# [language_server.ruff.settings._.globalSettings] +# organizeImports = true +# fixAll = true + [language_server.r-language-server] filetypes = ["r"] roots = ["DESCRIPTION", ".git", ".hg"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kak-lsp-15.0.0/rc/lsp.kak new/kak-lsp-15.0.1/rc/lsp.kak --- old/kak-lsp-15.0.0/rc/lsp.kak 2023-11-15 09:55:21.000000000 +0100 +++ new/kak-lsp-15.0.1/rc/lsp.kak 2023-12-11 10:05:46.000000000 +0100 @@ -387,13 +387,6 @@ } }} -declare-option -hidden bool lsp_have_kakoune_feature_filtertext -declare-option -hidden completions lsp_have_kakoune_feature_filtertext_tmp -try %{ - set-option global lsp_have_kakoune_feature_filtertext_tmp 1.1@0 insert_text|filter_text|on_select|menu - set-option global lsp_have_kakoune_feature_filtertext true -} - define-command -hidden lsp-completion -docstring "Request completions for the main cursor position" %{ try %{ # Fail if preceding character is a whitespace (by default; the trigger could be customized). @@ -425,8 +418,6 @@ column = ${kak_cursor_column} [params.completion] offset = ${kak_opt_lsp_completion_offset} -[params] -have_kakoune_feature_filtertext = ${kak_opt_lsp_have_kakoune_feature_filtertext} " | eval "${kak_opt_lsp_cmd} --request") > /dev/null 2>&1 < /dev/null & } }} @@ -518,9 +509,33 @@ declare-option -hidden str lsp_symbol_kind_completion %{ symbol_kinds="\ - File Module Namespace Package Class Method Property Field Constructor Enum Interface - Function Variable Constant String Number Boolean Array Object Key Null EnumMember Struct - Event Operator TypeParameter" + Array + Boolean + Class + Constant + Constructor + Enum + EnumMember + Event + Field + File + Function + Interface + Key + Method + Module + Namespace + Null + Number + Object + Operator + Package + Property + String + Struct + TypeParameter + Variable + " printf '%s\n' ${symbol_kinds} } @@ -579,7 +594,7 @@ } -shell-script-candidates %{ case $# in # Search forward or backward? - (1) printf '%s\n' previous next ;; + (1) printf '%s\n' next previous ;; # Show hover info or goto symbol? (2) printf '%s\n' hover goto ;; # Which symbol types? @@ -630,8 +645,19 @@ " | eval "${kak_opt_lsp_cmd} --request") > /dev/null 2>&1 < /dev/null & } } +define-command -hidden lsp-get-word-regex %{ + try %{ + execute-keys %exp{<a-i>c\A|[^\w%opt{lsp_extra_word_chars}],\z|[^\w%opt{lsp_extra_word_chars}]<ret>} + execute-keys %{"a*} + } catch %{ + set-register a %{} + } +} + define-command lsp-definition -docstring "Go to definition" %{ - nop %sh{ (printf %s " + evaluate-commands -draft -save-regs a %{ + lsp-get-word-regex + nop %sh{ (printf %s " session = \"${kak_session}\" client = \"${kak_client}\" buffile = \"${kak_buffile}\" @@ -639,11 +665,13 @@ version = ${kak_timestamp:-0} method = \"textDocument/definition\" $([ -z ${kak_hook_param+x} ] || echo hook = true) +word_regex = '''${kak_reg_a}''' ${kak_opt_lsp_connect_fifo}\ [params.position] line = ${kak_cursor_line} column = ${kak_cursor_column} " | eval "${kak_opt_lsp_cmd} --request") > /dev/null 2>&1 < /dev/null & } + } } define-command lsp-declaration -docstring "Go to declaration" %{ @@ -817,7 +845,9 @@ }} define-command lsp-references -docstring "Open buffer with symbol references" %{ - nop %sh{ (printf %s " + evaluate-commands -draft -save-regs a %{ + lsp-get-word-regex + nop %sh{ (printf %s " session = \"${kak_session}\" client = \"${kak_client}\" buffile = \"${kak_buffile}\" @@ -825,15 +855,19 @@ version = ${kak_timestamp:-0} method = \"textDocument/references\" $([ -z ${kak_hook_param+x} ] || echo hook = true) +word_regex = '''${kak_reg_a}''' ${kak_opt_lsp_connect_fifo}\ [params.position] line = ${kak_cursor_line} column = ${kak_cursor_column} " | eval "${kak_opt_lsp_cmd} --request") > /dev/null 2>&1 < /dev/null & } + } } define-command lsp-highlight-references -docstring "Highlight symbol references" %{ - nop %sh{ (printf %s " + evaluate-commands -draft -save-regs a %{ + lsp-get-word-regex + nop %sh{ (printf %s " session = \"${kak_session}\" client = \"${kak_client}\" buffile = \"${kak_buffile}\" @@ -841,11 +875,13 @@ version = ${kak_timestamp:-0} method = \"textDocument/documentHighlight\" $([ -z ${kak_hook_param+x} ] || echo hook = true) +word_regex = '''${kak_reg_a}''' ${kak_opt_lsp_connect_fifo}\ [params.position] line = ${kak_cursor_line} column = ${kak_cursor_column} " | eval "${kak_opt_lsp_cmd} --request") > /dev/null 2>&1 < /dev/null & } + } } define-command lsp-rename -params 1 -docstring "lsp-rename <new-name>: rename symbol under the main cursor" %{ @@ -1800,7 +1836,7 @@ lsp-show-message-log <message> Render language server message of the "log" level. } %{ - echo -debug "kak-lsp: [%arg{1}] log %arg{1}: %arg{2}" + echo -debug "kak-lsp: log from %arg{1}: %arg{2}" } define-command -hidden lsp-show-message-request -params 4.. -docstring %{ @@ -2301,7 +2337,7 @@ lsp-inline-diagnostics-disable window lsp-diagnostic-lines-disable window try %{ set-option -remove window completers option=lsp_completions } - set-option window lsp_fail_if_disabled fail + unset-option window lsp_fail_if_disabled remove-hooks window lsp remove-hooks global lsp-auto-hover remove-hooks global lsp-auto-hover-insert-mode @@ -2585,18 +2621,7 @@ # Deprecated commands. -define-command -hidden lsp -params 1.. -shell-script-candidates %{ - for cmd in start hover definition references signature-help diagnostics document-symbol\ - workspace-symbol workspace-symbol-incr rename rename-prompt\ - capabilities stop formatting formatting-sync highlight-references\ - inline-diagnostics-enable inline-diagnostics-disable\ - diagnostic-lines-enable diagnostic-lines-disable auto-hover-enable auto-hover-disable\ - auto-hover-insert-mode-enable auto-hover-insert-mode-disable auto-signature-help-enable\ - auto-signature-help-disable stop-on-exit-enable stop-on-exit-disable\ - find-error implementation; - do echo $cmd; - done -} %{ evaluate-commands "lsp-%arg{1}" } +define-command -hidden lsp -params 1.. %{ evaluate-commands "lsp-%arg{1}" } define-command -hidden lsp-symbols-next-match -docstring 'DEPRECATED, use lsp-next-location. Jump to the next symbols match' %{ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kak-lsp-15.0.0/src/capabilities.rs new/kak-lsp-15.0.1/src/capabilities.rs --- old/kak-lsp-15.0.0/src/capabilities.rs 2023-11-15 09:55:21.000000000 +0100 +++ new/kak-lsp-15.0.1/src/capabilities.rs 2023-12-11 10:05:46.000000000 +0100 @@ -248,6 +248,7 @@ "refactor.inline", "refactor.rewrite", "source", + "source.fixAll", "source.organizeImports", ] .iter() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kak-lsp-15.0.0/src/context.rs new/kak-lsp-15.0.1/src/context.rs --- old/kak-lsp-15.0.0/src/context.rs 2023-11-15 09:55:21.000000000 +0100 +++ new/kak-lsp-15.0.1/src/context.rs 2023-12-11 10:05:46.000000000 +0100 @@ -77,7 +77,7 @@ pub outstanding_requests: HashMap<(ServerName, &'static str, String, Option<String>), OutstandingRequests>, pub pending_requests: Vec<EditorRequest>, - pub pending_message_requests: VecDeque<(Id, ShowMessageRequestParams)>, + pub pending_message_requests: VecDeque<(Id, ServerName, ShowMessageRequestParams)>, pub request_counter: u64, pub response_waitlist: HashMap<Id, (EditorMeta, &'static str, BatchNumber, bool)>, pub session: SessionId, @@ -381,6 +381,7 @@ write_response_to_fifo: false, hook: false, server: None, + word_regex: None, } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kak-lsp-15.0.0/src/controller.rs new/kak-lsp-15.0.1/src/controller.rs --- old/kak-lsp-15.0.0/src/controller.rs 2023-11-15 09:55:21.000000000 +0100 +++ new/kak-lsp-15.0.1/src/controller.rs 2023-12-11 10:05:46.000000000 +0100 @@ -738,7 +738,7 @@ workspace::configuration(request.params, server_name, ctx) } request::ShowMessageRequest::METHOD => { - return show_message::show_message_request(meta, request, ctx); + return show_message::show_message_request(meta, server_name, request, ctx); } _ => { warn!("Unsupported method: {}", method); @@ -778,7 +778,7 @@ let params: ShowMessageParams = params .parse() .expect("Failed to parse ShowMessageParams params"); - show_message::show_message(meta, params.typ, ¶ms.message, ctx); + show_message::show_message(meta, server_name, params.typ, ¶ms.message, ctx); } "window/logMessage" => { let params: LogMessageParams = params diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kak-lsp-15.0.0/src/language_features/code_action.rs new/kak-lsp-15.0.1/src/language_features/code_action.rs --- old/kak-lsp-15.0.0/src/language_features/code_action.rs 2023-11-15 09:55:21.000000000 +0100 +++ new/kak-lsp-15.0.1/src/language_features/code_action.rs 2023-12-11 10:05:46.000000000 +0100 @@ -144,7 +144,7 @@ return; } - let actions: Vec<_> = results + let mut actions: Vec<_> = results .into_iter() .flat_map(|(server_name, cmd)| { let cmd: Vec<_> = cmd @@ -222,6 +222,25 @@ return; } + actions.sort_by_key(|(_server, ca)| { + // TODO Group by server? + let empty = CodeActionKind::EMPTY; + let kind = match ca { + CodeActionOrCommand::Command(_) => &empty, + CodeActionOrCommand::CodeAction(action) => action.kind.as_ref().unwrap_or(&empty), + }; + // TODO These loosely follow what VSCode does, we should be more accurate. + match kind.as_str() { + "quickfix" => 0, + "refactor" => 1, + "refactor.extract" => 2, + "refactor.inline" => 3, + "refactor.rewrite" => 4, + "source" => 5, + "source.organizeImports" => 6, + _ => 7, + } + }); let titles_and_commands = actions .iter() .map(|(server_name, c)| { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kak-lsp-15.0.0/src/language_features/completion.rs new/kak-lsp-15.0.1/src/language_features/completion.rs --- old/kak-lsp-15.0.0/src/language_features/completion.rs 2023-11-15 09:55:21.000000000 +0100 +++ new/kak-lsp-15.0.1/src/language_features/completion.rs 2023-12-11 10:05:46.000000000 +0100 @@ -51,13 +51,17 @@ ); } +fn sort_text(item: &CompletionItem) -> &str { + item.sort_text.as_ref().unwrap_or(&item.label) +} + fn editor_completion( meta: EditorMeta, params: TextDocumentCompletionParams, results: Vec<(String, Option<CompletionResponse>)>, ctx: &mut Context, ) { - let items = results + let mut items: Vec<(String, CompletionItem)> = results .into_iter() .flat_map(|(server_name, items)| { let items = match items { @@ -70,6 +74,11 @@ }) .collect(); + // TODO Group by server? + items.sort_by(|(_left_server, left), (_right_server, right)| { + sort_text(left).cmp(sort_text(right)) + }); + let version = meta.version; ctx.completion_items = items; ctx.completion_items_timestamp = version; @@ -178,64 +187,15 @@ .or_else(|| x.insert_text.clone()) .unwrap_or_else(|| x.label.clone()); - fn completion_entry( - insert_text: &str, - maybe_filter_text: &Option<String>, - on_select: &str, - menu: &str, - ) -> String { - if let Some(filter_text) = maybe_filter_text { - editor_quote(&format!( - "{}|{}|{}|{}", - escape_tuple_element(insert_text), - escape_tuple_element(filter_text), - escape_tuple_element(on_select), - escape_tuple_element(menu), - )) - } else { - editor_quote(&format!( - "{}|{}|{}", - escape_tuple_element(insert_text), - escape_tuple_element(on_select), - escape_tuple_element(menu), - )) - } + fn completion_entry(insert_text: &str, on_select: &str, menu: &str) -> String { + editor_quote(&format!( + "{}|{}|{}", + escape_tuple_element(insert_text), + escape_tuple_element(on_select), + escape_tuple_element(menu), + )) } - let maybe_filter_text = { - let specified_filter_text = x.filter_text.as_ref().unwrap_or(&x.label); - let specified_insert_text = x - .text_edit - .as_ref() - .map(|cte| match cte { - CompletionTextEdit::Edit(text_edit) => &text_edit.new_text, - CompletionTextEdit::InsertAndReplace(text_edit) => &text_edit.new_text, - }) - .or(x.insert_text.as_ref()) - .unwrap_or(&x.label); - if !params.have_kakoune_feature_filtertext - && specified_filter_text != specified_insert_text - && x.insert_text_format != Some(InsertTextFormat::SNIPPET) - { - // Simulate filter-text support by giving the filter-text to Kakoune - // but expand to the insert-text when the completion is accepted. - let command = formatdoc!( - "{on_select} - lsp-snippets-insert-completion {}", - editor_quote(&(insert_text + "$0")) - ); - let insert_text = specified_filter_text; - return completion_entry(insert_text, &None, &command, &entry); - } - if params.have_kakoune_feature_filtertext - && specified_filter_text != specified_insert_text - { - Some(specified_filter_text.clone()) - } else { - None - } - }; - // If snippet support is both enabled and provided by the server, // we'll need to perform some transformations on the completion commands. if ctx.config.snippet_support && x.insert_text_format == Some(InsertTextFormat::SNIPPET) @@ -260,9 +220,33 @@ editor_quote(&snippet) ); - completion_entry(&insert_text, &maybe_filter_text, &command, &entry) + completion_entry(&insert_text, &command, &entry) } else { - completion_entry(&insert_text, &maybe_filter_text, &on_select, &entry) + // Due to implementation reasons, we currently do not support filter text + // with snippets. + let specified_filter_text = x.filter_text.as_ref().unwrap_or(&x.label); + let specified_insert_text = x + .text_edit + .as_ref() + .map(|cte| match cte { + CompletionTextEdit::Edit(text_edit) => &text_edit.new_text, + CompletionTextEdit::InsertAndReplace(text_edit) => &text_edit.new_text, + }) + .or(x.insert_text.as_ref()) + .unwrap_or(&x.label); + let (insert_text, on_select) = if specified_filter_text != specified_insert_text { + // Simulate filter-text support by giving the filter-text to Kakoune + // but expand to the insert-text when the completion is accepted. + let on_select = formatdoc!( + "{on_select} + lsp-snippets-insert-completion {}", + editor_quote(&(insert_text + "$0")) + ); + (specified_filter_text, on_select) + } else { + (&insert_text, on_select) + }; + completion_entry(insert_text, &on_select, &entry) } }) .join(" "); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kak-lsp-15.0.0/src/session.rs new/kak-lsp-15.0.1/src/session.rs --- old/kak-lsp-15.0.0/src/session.rs 2023-11-15 09:55:21.000000000 +0100 +++ new/kak-lsp-15.0.1/src/session.rs 2023-12-11 10:05:46.000000000 +0100 @@ -6,8 +6,10 @@ use crate::types::*; use crate::util::*; use crossbeam_channel::{after, never, select, Sender}; +use indoc::formatdoc; use lazy_static::lazy_static; use lsp_types::notification::Notification; +use lsp_types::request::Request; use lsp_types::*; use regex::Regex; use std::collections::HashMap; @@ -110,7 +112,7 @@ .iter() .map(|server_name| { let language = &languages[server_name]; - let root = find_project_root(&language_id, &language.roots, &request.meta.buffile); + let root = find_project_root(language_id, &language.roots, &request.meta.buffile); let route = Route { session: request.meta.session.clone(), server_name: server_name.clone(), @@ -201,7 +203,35 @@ /// This will cancel any blocking requests and also print an error if the /// request was not triggered by an editor hook. fn return_request_error(to_editor: &Sender<EditorResponse>, request: &EditorRequest, msg: &str) { - let command = format!("lsp-show-error {}", editor_quote(msg)); + let word_regex = request.meta.word_regex.as_ref(); + let command = + if let Some(multi_cmds) = + match request.method.as_str() { + _ if request.meta.hook => None, + request::GotoDefinition::METHOD | request::References::METHOD => Some(formatdoc!( + "grep {} + lsp-show-error {}", + editor_quote(word_regex.unwrap()), + editor_quote(msg), + )), + request::DocumentHighlightRequest::METHOD => Some(formatdoc!( + "evaluate-commands -save-regs a/^ %| + execute-keys -save-regs '' %[\"aZ] + set-register / {} + execute-keys -save-regs '' <percent>s<ret>Z + execute-keys %[\"az<a-z>a] + | + lsp-show-error {}", + editor_quote(word_regex.unwrap()).replace('|', "||"), + editor_quote( + &format!("{msg}, falling_back to %s{}<ret>", word_regex.unwrap())) + )), + _ => None, + } { + format!( "evaluate-commands {}", &editor_quote(&multi_cmds)) + }else { + format!("lsp-show-error {}", editor_quote(msg)) + }; // If editor is expecting a fifo response, give it one, so it won't hang. if let Some(ref fifo) = request.meta.fifo { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kak-lsp-15.0.0/src/show_message.rs new/kak-lsp-15.0.1/src/show_message.rs --- old/kak-lsp-15.0.0/src/show_message.rs 2023-11-15 09:55:21.000000000 +0100 +++ new/kak-lsp-15.0.1/src/show_message.rs 2023-12-11 10:05:46.000000000 +0100 @@ -5,20 +5,30 @@ use lsp_types::{MessageActionItem, MessageType, ShowMessageRequestParams}; use serde::Deserialize; -use crate::{context::Context, types::EditorMeta, util::editor_quote}; +use crate::{ + context::Context, + types::{EditorMeta, ServerName}, + util::editor_quote, +}; // commands to be handled pub const SHOW_MESSAGE_REQUEST_NEXT: &str = "window/showMessageRequest/showNext"; pub const SHOW_MESSAGE_REQUEST_RESPOND: &str = "window/showMessageRequest/respond"; /// Queues the message request from the LSP server. -pub fn show_message_request(meta: EditorMeta, request: MethodCall, ctx: &mut Context) { +pub fn show_message_request( + meta: EditorMeta, + server_name: &ServerName, + request: MethodCall, + ctx: &mut Context, +) { let request_id = request.id; let params: ShowMessageRequestParams = request .params .parse() .expect("Failed to parse ShowMessageRequest params"); - ctx.pending_message_requests.push_back((request_id, params)); + ctx.pending_message_requests + .push_back((request_id, server_name.clone(), params)); update_modeline(meta, ctx) } @@ -46,7 +56,7 @@ } pub fn show_message_request_next(meta: EditorMeta, ctx: &mut Context) { - let (id, params) = match ctx.pending_message_requests.pop_front() { + let (id, server_name, params) = match ctx.pending_message_requests.pop_front() { Some(v) => v, None => { return ctx.exec(meta, "lsp-show-error 'No pending message requests.'"); @@ -57,12 +67,9 @@ Some(opts) if !opts.is_empty() => &opts[..], _ => { // a ShowMessageRequest with no actions is just a ShowMessage notification. - show_message(meta, params.typ, ¶ms.message, ctx); + show_message(meta, &server_name, params.typ, ¶ms.message, ctx); - let servers: Vec<_> = ctx.language_servers.keys().cloned().collect(); - for server_name in &servers { - ctx.reply(server_name, id.clone(), Ok(serde_json::Value::Null)); - } + ctx.reply(&server_name, id.clone(), Ok(serde_json::Value::Null)); return; } }; @@ -101,9 +108,23 @@ } /// Implements ShowMessage notification. -pub fn show_message(meta: EditorMeta, typ: MessageType, msg: &str, ctx: &Context) { +pub fn show_message( + meta: EditorMeta, + server_name: &ServerName, + typ: MessageType, + msg: &str, + ctx: &Context, +) { let command = message_type(typ).unwrap_or("nop"); - ctx.exec(meta, format!("{} {}", command, editor_quote(msg))); + ctx.exec( + meta, + format!( + "{} {} {}", + command, + editor_quote(server_name), + editor_quote(msg) + ), + ); } fn update_modeline(meta: EditorMeta, ctx: &Context) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kak-lsp-15.0.0/src/types.rs new/kak-lsp-15.0.1/src/types.rs --- old/kak-lsp-15.0.0/src/types.rs 2023-11-15 09:55:21.000000000 +0100 +++ new/kak-lsp-15.0.1/src/types.rs 2023-12-11 10:05:46.000000000 +0100 @@ -146,6 +146,7 @@ #[serde(default)] pub hook: bool, pub server: Option<ServerName>, + pub word_regex: Option<String>, } pub type EditorParams = toml::Value; @@ -205,7 +206,6 @@ pub struct TextDocumentCompletionParams { pub position: KakounePosition, pub completion: EditorCompletion, - pub have_kakoune_feature_filtertext: bool, } #[derive(Serialize, Deserialize, Debug)] ++++++ vendor.tar.zst ++++++ Binary files /var/tmp/diff_new_pack.5BCh4f/_old and /var/tmp/diff_new_pack.5BCh4f/_new differ
participants (1)
-
Source-Sync