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-07-19 15:27:30 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kak-lsp (Old) and /work/SRC/openSUSE:Factory/.kak-lsp.new.17339 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kak-lsp" Fri Jul 19 15:27:30 2024 rev:11 rq:1188340 version:17.1.1 Changes: -------- --- /work/SRC/openSUSE:Factory/kak-lsp/kak-lsp.changes 2024-06-05 17:43:11.711842592 +0200 +++ /work/SRC/openSUSE:Factory/.kak-lsp.new.17339/kak-lsp.changes 2024-07-19 15:27:37.411870775 +0200 @@ -1,0 +2,13 @@ +Thu Jul 18 04:13:32 UTC 2024 - Soc Virnyl Estela <[email protected]> + +- Update to version 17.1.1: + * Default configuration for Svelte via svelte-language-server. + * The language server stderr is logged eagerly instead of only after server exit; (useful for when servers like rust-analyzer crash). + * Support dynamic for registration semantic tokens via textDocument/semanticTokens. + * lsp-code-actions has learned to filter by code action kind. This should obsolete the lsp-code-action command which has been hidden and deprecated. + * lsp-code-actions learned the -auto-single switch to instantly run if there is only one matching code action. + * Fixed a case where a legacy `kak-lsp.toml` specifying the same server for multiple languages would drop all but one language. + * Some hover info had extra trailing whitespace, which is now trimmed properly. + * Hover info containing ASCII-art tables as popular in some flavors of Markdown is now rendered properly. The default config now enables inlay hints also for recent version of Scala Metals. + +------------------------------------------------------------------- Old: ---- kak-lsp-17.0.1.tar.gz New: ---- kak-lsp-17.1.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kak-lsp.spec ++++++ --- /var/tmp/diff_new_pack.IBRLg8/_old 2024-07-19 15:27:39.223942875 +0200 +++ /var/tmp/diff_new_pack.IBRLg8/_new 2024-07-19 15:27:39.223942875 +0200 @@ -17,7 +17,7 @@ Name: kak-lsp -Version: 17.0.1 +Version: 17.1.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-17.0.1.tar.gz -> kak-lsp-17.1.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/.github/workflows/test.yml new/kakoune-lsp-17.1.1/.github/workflows/test.yml --- old/kakoune-lsp-17.0.1/.github/workflows/test.yml 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/.github/workflows/test.yml 2024-06-27 10:42:05.000000000 +0200 @@ -64,12 +64,12 @@ id: kakoune-commit-id run: echo "::set-output name=id::$(git -C $GITHUB_WORKSPACE/kakoune rev-parse HEAD)" - - name: Install gcc 10 via homebrew - if: matrix.kakoune_version == '' && matrix.os == 'macos-latest' - run: brew install gcc@10 + - name: Install clang via homebrew + if: matrix.os == 'macos-latest' + run: brew install llvm@13 - name: Install gcc 10 via apt - if: matrix.kakoune_version == '' && matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-latest' run: | sudo apt-get update sudo apt-get install -y --no-install-recommends gcc-10 @@ -90,8 +90,10 @@ - name: Build Kakoune working-directory: ${{ github.workspace }}/kakoune/src run: | - if [ "${{ matrix.kakoune_version }}" = "" ]; then - export CXX=g++-10 + if [ "${{ matrix.os }}" = "macos-latest" ]; then + CXX=/opt/homebrew/opt/llvm@13/bin/clang++ + else + CXX=g++-10 fi if [ "${{ steps.cache-kakoune.outputs.cache-hit }}" ]; then # The source files created by actions/checkout are newer than the @@ -99,13 +101,17 @@ # to tell "make install" that they are indeed up-to-date. make -t else - make -j$([ "${{ matrix.os }}" = "macos-latest" ] && sysctl -n hw.logicalcpu || nproc) + make CXX=$CXX -j$([ "${{ matrix.os }}" = "macos-latest" ] && sysctl -n hw.logicalcpu || nproc) fi - sudo --preserve-env=CXX make install + sudo make CXX=$CXX install + + - name: Install Go via homebrew + if: matrix.os == 'macos-latest' + run: brew install go - name: Install gopls run: | - go install golang.org/x/tools/[email protected] + go install golang.org/x/tools/[email protected] sudo ln "$HOME/go/bin/gopls" /usr/local/bin/ - name: Install rust-analyzer diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/CHANGELOG.md new/kakoune-lsp-17.1.1/CHANGELOG.md --- old/kakoune-lsp-17.0.1/CHANGELOG.md 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/CHANGELOG.md 2024-06-27 10:42:05.000000000 +0200 @@ -1,3 +1,19 @@ +## 17.1.1 - 2024-06-27 + +Additions: +- Default configuration for Svelte via [svelte-language-server](https://github.com/sveltejs/language-tools). +- The language server stderr is logged eagerly instead of only after server exit; (useful for when servers like rust-analyzer crash). +- Support dynamic for registration semantic tokens via `textDocument/semanticTokens`. +- `lsp-code-actions` has learned to filter by code action kind. + This should obsolete the `lsp-code-action` command which has been hidden and deprecated. +- `lsp-code-actions` learned the `-auto-single` switch to instantly run if there is only one matching code action. +- The default config now enables inlay hints also for recent version of Scala Metals. + +Fixes: +- Fixed a case where a legacy `kak-lsp.toml` specifying the same server for multiple languages would drop all but one language. +- Some hover info had extra trailing whitespace, which is now trimmed properly. +- Hover info containing ASCII-art tables as popular in some flavors of Markdown is now rendered properly. + ## 17.0.1 - 2024-04-06 Small patch release to fix a regression. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/Cargo.lock new/kakoune-lsp-17.1.1/Cargo.lock --- old/kakoune-lsp-17.0.1/Cargo.lock 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/Cargo.lock 2024-06-27 10:42:05.000000000 +0200 @@ -611,7 +611,7 @@ [[package]] name = "kak-lsp" -version = "17.0.1" +version = "17.1.1" dependencies = [ "clap", "crossbeam-channel", @@ -641,7 +641,6 @@ "sloggers", "toml", "unicode-width", - "unindent", "url", "whoami", ] @@ -1445,12 +1444,6 @@ checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] -name = "unindent" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" - -[[package]] name = "url" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/Cargo.toml new/kakoune-lsp-17.1.1/Cargo.toml --- old/kakoune-lsp-17.0.1/Cargo.toml 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/Cargo.toml 2024-06-27 10:42:05.000000000 +0200 @@ -1,7 +1,7 @@ [package] name = "kak-lsp" description = "Kakoune Language Server Protocol Client" -version = "17.0.1" +version = "17.1.1" authors = ["Ruslan Prokopchuk <[email protected]>", "Johannes Altmanninger <[email protected]>"] edition = "2018" license = "Unlicense/MIT" @@ -36,7 +36,6 @@ slog = { version = "2.5.2", features = ["release_max_level_debug"] } toml = "0.8.8" unicode-width = "0.1.10" -unindent = "0.2.3" url = { version = "2.1.1", features = ["serde"] } whoami = "1.1.3" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/README.asciidoc new/kakoune-lsp-17.1.1/README.asciidoc --- old/kakoune-lsp-17.0.1/README.asciidoc 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/README.asciidoc 2024-06-27 10:42:05.000000000 +0200 @@ -26,8 +26,8 @@ [source,sh] ---- -curl -O -L https://github.com/kakoune-lsp/kakoune-lsp/releases/download/v17.0.1/kakoune-lsp-v17.0.1-x86_64-apple-darwin.tar.gz -tar xzvf kakoune-lsp-v17.0.1-x86_64-apple-darwin.tar.gz +curl -O -L https://github.com/kakoune-lsp/kakoune-lsp/releases/download/v17.1.1/kakoune-lsp-v17.1.1-x86_64-apple-darwin.tar.gz +tar xzvf kakoune-lsp-v17.1.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/kakoune-lsp/kakoune-lsp/releases/download/v17.0.1/kakoune-lsp-v17.0.1-x86_64-unknown-linux-musl.tar.gz -tar xzvf kak-lsp-v17.0.1-x86_64-unknown-linux-musl.tar.gz +wget https://github.com/kakoune-lsp/kakoune-lsp/releases/download/v17.1.1/kakoune-lsp-v17.1.1-x86_64-unknown-linux-musl.tar.gz +tar xzvf kak-lsp-v17.1.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/kakoune-lsp-17.0.1/ci/build-release.sh new/kakoune-lsp-17.1.1/ci/build-release.sh --- old/kakoune-lsp-17.0.1/ci/build-release.sh 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/ci/build-release.sh 2024-06-27 10:42:05.000000000 +0200 @@ -14,6 +14,7 @@ sh -s -- --force --git rust-embedded/cross --tag v0.2.1 --target $target command -v cross || PATH=~/.cargo/bin:$PATH +rustup target add $target cross build --target $target --release cross test --target $target --release diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/ci/commit-new-release.sh new/kakoune-lsp-17.1.1/ci/commit-new-release.sh --- old/kakoune-lsp-17.0.1/ci/commit-new-release.sh 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/ci/commit-new-release.sh 2024-06-27 10:42:05.000000000 +0200 @@ -52,6 +52,7 @@ done sha=$(sha256sum "$archive") sha=${sha%% *} +rm "$archive" ( cd ../homebrew-kakoune-lsp/ sed 4c" url \"$url\"" -i Formula/kakoune-lsp.rb diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/kak-lsp.toml new/kakoune-lsp-17.1.1/kak-lsp.toml --- old/kakoune-lsp-17.0.1/kak-lsp.toml 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/kak-lsp.toml 2024-06-27 10:42:05.000000000 +0200 @@ -81,8 +81,13 @@ [language_server.metals.settings.metals] icons = "unicode" isHttpEnabled = true -statusBarProvider = "log-message" +statusBarProvider = "show-message" compilerOptions = { overrideDefFormat = "unicode" } +inlayHints.hintsInPatternMatch.enable = true +inlayHints.implicitArguments.enable = true +inlayHints.implicitConversions.enable = true +inlayHints.inferredTypes.enable = true +inlayHints.typeParameters.enable = true [language_server.nil] filetypes = ["nix"] @@ -263,6 +268,12 @@ command = "marksman" args = ["server"] +# [language_server.zk] +# filetypes = ["markdown"] +# roots = [".zk"] +# command = "zk" +# args = ["lsp"] + [language_server.nimlsp] filetypes = ["nim"] roots = ["*.nimble", ".git", ".hg"] @@ -376,6 +387,12 @@ # See https://github.com/castwide/solargraph/blob/master/lib/solargraph/language_server/host.rb # diagnostics = false +[language_server.svelte-language-server] +filetypes = ["svelte"] +roots = ["package.json", "tsconfig.json", "jsconfig.json", ".git", ".hg"] +command = "svelteserver" +args = ["--stdio"] + [language_server.taplo] filetypes = ["toml"] roots = [".git", ".hg"] @@ -429,6 +446,12 @@ # quotePreference = "double" # typescript.format.semicolons = "insert" +# [language_server.biome] +# filetypes = ["typescript", "javascript"] +# roots = ["biome.json", "package.json", "tsconfig.json", "jsconfig.json", ".git", ".hg"] +# command = "biome" +# args = ["lsp-proxy"] + # [language_server.eslint] # filetypes = ["javascript", "typescript"] # roots = [".eslintrc", ".eslintrc.json"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/rc/lsp.kak new/kakoune-lsp-17.1.1/rc/lsp.kak --- old/kakoune-lsp-17.0.1/rc/lsp.kak 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/rc/lsp.kak 2024-06-27 10:42:05.000000000 +0200 @@ -281,7 +281,7 @@ define-command -hidden lsp-menu-impl %{ evaluate-commands %sh{ if ! command -v perl > /dev/null; then - printf "fail %{'perl' must be installed to use the 'lsp-menu' command}" + echo "lsp-show-error %{'perl' must be installed to use the 'lsp-menu' command}" exit fi echo >$kak_command_fifo "echo -to-file $kak_response_fifo -quoting kakoune -- %reg{a}" @@ -324,7 +324,7 @@ my $auto_single = 0; my $select_cmds = 0; my $on_abort = ""; - while (defined $args[0] && $args[0] =~ m/^-/) { + while (defined $args[0] and $args[0] =~ m/^-/) { if ($args[0] eq "--") { shift @args; last; @@ -350,8 +350,8 @@ print "fail %{menu: wrong argument count}"; exit; } - if ($auto_single && scalar @args == $stride) { - print $args[$0]; + if ($auto_single and scalar @args == $stride) { + print $args[1]; exit; } @@ -411,7 +411,7 @@ } print " -menu -shell-script-candidates %{cat $shell_script_candidates}"; ' || - echo 'fail menu: encountered an error, see *debug* buffer'; + echo 'lsp-show-error %{lsp-menu: encountered an error, see *debug* buffer}'; } } define-command -hidden lsp-with-option -params 3.. -docstring %{ @@ -873,26 +873,59 @@ " | eval "${kak_opt_lsp_cmd} --request") > /dev/null 2>&1 < /dev/null & } } -define-command lsp-code-actions -docstring "Perform code actions for the main cursor position" %{ - lsp-code-actions-request true +define-command lsp-code-actions -params 0.. -docstring %{ + lsp-code-actions [-auto-single] [<code-action-kinds>...]: Perform code actions for the main cursor position + + If <code-action-kinds> is given, only show matching code actions. + With -auto-single instantly validate if only one code action is available. +} %{ + lsp-code-actions-request true false only %arg{@} +} -shell-script-candidates %{ +cat <<EOF +-auto-single +quickfix +refactor +refactor.extract +refactor.inline +refactor.rewrite +refactor.rewrite +source +source.fixAll +source.organizeImports +EOF +} + +define-command lsp-code-actions-sync -params 0.. -docstring %{ + lsp-code-actions-sync [<code-action-kinds>...]: Perform the matching code action for the main cursor position, blocking Kakoune session until done. +} %{ + lsp-code-actions-request true true only %arg{@} +} -shell-script-candidates %{ +cat <<EOF +quickfix +refactor +refactor.extract +refactor.inline +refactor.rewrite +refactor.rewrite +source +source.fixAll +source.organizeImports +EOF } -define-command lsp-code-action -params 1 -docstring "lsp-code-action <pattern>: perform the code action that matches the given regex" %{ - lsp-code-actions-request true %arg{1} false +define-command -hidden lsp-code-action -params 1 -docstring "DEPRECATED lsp-code-action <pattern>: perform the code action that matches the given regex" %{ + lsp-code-actions-request true false matching %arg{1} } -define-command lsp-code-action-sync -params 1 -docstring "lsp-code-action-sync <pattern>: perform the code action that matches the given regex, blocking Kakoune session until done" %{ +define-command -hidden lsp-code-action-sync -params 1 -docstring "DEPRECATED lsp-code-action-sync <pattern>: perform the code action that matches the given regex, blocking Kakoune session until done" %{ lsp-require-enabled lsp-code-action-sync lsp-did-change-sync - lsp-code-actions-request true %arg{1} true + lsp-code-actions-request true true matching %arg{1} } -define-command -hidden lsp-code-actions-request -params 1..3 -docstring "Request code actions for the main cursor position" %{ evaluate-commands -no-hooks %sh{ - code_action_pattern="" - if [ $# -ge 2 ]; then - code_action_pattern="codeActionPattern = \"$(printf %s "$2" | sed 's/\\/\\\\/g; s/"/\\"/g')\"" - fi - sync=${3:-false} +define-command -hidden lsp-code-actions-request -params 1.. -docstring "Request code actions for the main cursor position" %{ evaluate-commands -no-hooks %sh{ + do_perform=$1 + sync=$2 fifo="" if "$sync"; then tmp=$(mktemp -q -d -t 'kak-lsp-sync.XXXXXX' 2>/dev/null || mktemp -q -d) @@ -904,6 +937,28 @@ " fi + auto_single=false + only= + code_action_pattern= + if [ $# -gt 3 ]; then + filter_mode=$3 + shift 3 + case "$filter_mode" in + (only) + if [ "$1" = -auto-single ]; then + auto_single=true + shift + fi + if [ $# -gt 0 ]; then + only="only = \"$(printf %s "$*" | sed 's/\\/\\\\/g; s/"/\\"/g')\"" + fi + ;; + (matching) + code_action_pattern="codeActionPattern = \"$(printf %s "$1" | sed 's/\\/\\\\/g; s/"/\\"/g')\"" + ;; + esac + fi + (printf %s " session = \"${kak_session}\" client = \"${kak_client}\" @@ -915,7 +970,9 @@ ${fifo}\ [params] selectionDesc = \"${kak_selection_desc}\" -performCodeAction = $1 +performCodeAction = $do_perform +autoSingle = $auto_single +$only $code_action_pattern " | eval "${kak_opt_lsp_cmd} --request") > /dev/null 2>&1 < /dev/null & @@ -2347,7 +2404,7 @@ lsp-did-change evaluate-commands %sh{ if $kak_opt_lsp_auto_highlight_references; then echo lsp-highlight-references; fi - if $kak_opt_lsp_auto_show_code_actions; then echo "lsp-code-actions-request false"; fi + if $kak_opt_lsp_auto_show_code_actions; then echo "lsp-code-actions-request false false"; fi } } hook -group lsp %arg{1} NormalKey (<a-i>|<a-a>|\[|\]|\{|\}|<a-\[>|<a-\]>|<a-\{>|<a-\}>) %{ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/src/capabilities.rs new/kakoune-lsp-17.1.1/src/capabilities.rs --- old/kakoune-lsp-17.0.1/src/capabilities.rs 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/src/capabilities.rs 2024-06-27 10:42:05.000000000 +0200 @@ -295,7 +295,7 @@ dynamic_registration: None, }), semantic_tokens: Some(SemanticTokensClientCapabilities { - dynamic_registration: Some(false), + dynamic_registration: Some(true), requests: SemanticTokensClientCapabilitiesRequests { range: Some(false), full: Some(SemanticTokensFullOptions::Bool(true)), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/src/controller.rs new/kakoune-lsp-17.1.1/src/controller.rs --- old/kakoune-lsp-17.0.1/src/controller.rs 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/src/controller.rs 2024-06-27 10:42:05.000000000 +0200 @@ -717,6 +717,34 @@ // "workspace/didChangeWorkspaceFolders" anyway, so let's not issue a warning. continue; } + "textDocument/semanticTokens" => { + let Some(options) = registration.register_options else { + warn!("semantic tokens registration without options"); + continue; + }; + let semantic_tokens_options: SemanticTokensOptions = + serde_json::from_value(options).unwrap(); + let semantic_tokens_server_capabilities = + SemanticTokensServerCapabilities::SemanticTokensRegistrationOptions( + SemanticTokensRegistrationOptions { + text_document_registration_options: + TextDocumentRegistrationOptions { + document_selector: None, + }, + semantic_tokens_options, + static_registration_options: StaticRegistrationOptions { + id: Some(registration.id), + }, + }, + ); + ctx.language_servers + .get_mut(server_name) + .unwrap() + .capabilities + .as_mut() + .unwrap() + .semantic_tokens_provider = Some(semantic_tokens_server_capabilities); + } _ => warn!("Unsupported registration: {}", registration.method), } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/src/diagnostics.rs new/kakoune-lsp-17.1.1/src/diagnostics.rs --- old/kakoune-lsp-17.0.1/src/diagnostics.rs 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/src/diagnostics.rs 2024-06-27 10:42:05.000000000 +0200 @@ -273,32 +273,35 @@ main_settings: &ServerSettings, ctx: &Context, ) -> Option<String> { - d.related_information.as_ref().map(|infos| { - "\n".to_string() - + &infos - .iter() - .map(|info| { - let path = info.location.uri.to_file_path().unwrap(); - let filename = path.to_str().unwrap(); - let p = get_kakoune_position_with_fallback( - server, - filename, - info.location.range.start, - ctx, - ); - format!( - "{}:{}:{}: {}{}", - short_file_path(filename, &main_settings.root_path), - p.line, - p.column, - &if ctx.language_servers.len() > 1 { - format!("[{server_name}] ") - } else { - "".to_string() - }, - info.message - ) - }) - .join("\n") - }) + d.related_information + .as_ref() + .filter(|infos| !infos.is_empty()) + .map(|infos| { + "\n".to_string() + + &infos + .iter() + .map(|info| { + let path = info.location.uri.to_file_path().unwrap(); + let filename = path.to_str().unwrap(); + let p = get_kakoune_position_with_fallback( + server, + filename, + info.location.range.start, + ctx, + ); + format!( + "{}:{}:{}: {}{}", + short_file_path(filename, &main_settings.root_path), + p.line, + p.column, + &if ctx.language_servers.len() > 1 { + format!("[{server_name}] ") + } else { + "".to_string() + }, + info.message + ) + }) + .join("\n") + }) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/src/language_features/code_action.rs new/kakoune-lsp-17.1.1/src/language_features/code_action.rs --- old/kakoune-lsp-17.0.1/src/language_features/code_action.rs 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/src/language_features/code_action.rs 2024-06-27 10:42:05.000000000 +0200 @@ -95,7 +95,11 @@ range: *range, context: CodeActionContext { diagnostics: diagnostics.remove(server_name).unwrap_or_default(), - only: None, + only: params.only.as_ref().map(|only| { + only.split(' ') + .map(|s| CodeActionKind::from(s.to_string())) + .collect() + }), trigger_kind: Some(if meta.hook { CodeActionTriggerKind::AUTOMATIC } else { @@ -181,41 +185,45 @@ .map(|(server_name, _)| server_name) .collect(); - if let Some(pattern) = params.code_action_pattern.as_ref() { - let regex = match regex::Regex::new(pattern) { - Ok(regex) => regex, - Err(error) => { - let command = format!( - "lsp-show-error 'invalid pattern: {}'", - &editor_escape(&error.to_string()) - ); - ctx.exec(meta, command); - return; - } + let sync = meta.fifo.is_some(); + if sync || params.code_action_pattern.is_some() { + let actions = if let Some(pattern) = params.code_action_pattern.as_ref() { + let regex = match regex::Regex::new(pattern) { + Ok(regex) => regex, + Err(error) => { + let command = format!( + "lsp-show-error 'invalid pattern: {}'", + &editor_escape(&error.to_string()) + ); + ctx.exec(meta, command); + return; + } + }; + actions + .into_iter() + .filter(|(_, c)| { + let title = match c { + CodeActionOrCommand::Command(command) => &command.title, + CodeActionOrCommand::CodeAction(action) => &action.title, + }; + regex.is_match(title) + }) + .collect::<Vec<_>>() + } else { + actions }; - let matches = actions - .iter() - .filter(|(_, c)| { - let title = match c { - CodeActionOrCommand::Command(command) => &command.title, - CodeActionOrCommand::CodeAction(action) => &action.title, - }; - regex.is_match(title) - }) - .collect::<Vec<_>>(); - let sync = meta.fifo.is_some(); let fail = if sync { // We might be running from a hook, so let's allow silencing errors with a "try". // Also, prefix with the (presumable) function name, to reduce confusion. - "fail lsp-code-action:" + "fail lsp-code-actions:" } else { "lsp-show-error" } .to_string(); - let command = match matches.len() { + let command = match actions.len() { 0 => fail + " 'no matching action available'", 1 => { - let (server_name, cmd) = matches[0]; + let (server_name, cmd) = &actions[0]; let may_resolve = may_resolve.contains(server_name); code_action_or_command_to_editor_command(cmd, sync, may_resolve) } @@ -247,21 +255,27 @@ _ => 7, } }); - let titles_and_commands = actions - .iter() - .map(|(server_name, c)| { - let mut title: &str = match c { - CodeActionOrCommand::Command(command) => &command.title, - CodeActionOrCommand::CodeAction(action) => &action.title, - }; - if let Some((head, _)) = title.split_once('\n') { - title = head - } - let may_resolve = may_resolve.contains(server_name); - let select_cmd = code_action_or_command_to_editor_command(c, false, may_resolve); - format!("{} {}", editor_quote(title), editor_quote(&select_cmd)) - }) - .join(" "); + let titles_and_commands = if params.auto_single { + "-auto-single " + } else { + "" + } + .to_string() + + &actions + .iter() + .map(|(server_name, c)| { + let mut title: &str = match c { + CodeActionOrCommand::Command(command) => &command.title, + CodeActionOrCommand::CodeAction(action) => &action.title, + }; + if let Some((head, _)) = title.split_once('\n') { + title = head + } + let may_resolve = may_resolve.contains(server_name); + let select_cmd = code_action_or_command_to_editor_command(c, false, may_resolve); + format!("{} {}", editor_quote(title), editor_quote(&select_cmd)) + }) + .join(" "); #[allow(clippy::collapsible_else_if)] let command = if params.perform_code_action { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/src/language_features/completion.rs new/kakoune-lsp-17.1.1/src/language_features/completion.rs --- old/kakoune-lsp-17.0.1/src/language_features/completion.rs 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/src/language_features/completion.rs 2024-06-27 10:42:05.000000000 +0200 @@ -146,12 +146,12 @@ None => escape_kakoune_markup(&x.label), }; - let insert_text = x.text_edit.as_ref().and_then(|cte| { + let is_simple_text_edit = x.text_edit.as_ref().is_some_and(|cte| { let document = match ctx.documents.get(&meta.buffile) { Some(doc) => doc, None => { warn!("No document in context for file: {}", &meta.buffile); - return None; + return false; } }; @@ -177,25 +177,25 @@ _ => (), } }; - - if range.start.line == params.position.line + range.start.line == params.position.line && range.end.line == params.position.line - { - Some(text_edit.new_text.clone()) - } else { - None - } } - CompletionTextEdit::InsertAndReplace(_) => None, + CompletionTextEdit::InsertAndReplace(_) => false, } }); - if insert_text.is_none() { + if !is_simple_text_edit { can_infer_offset = false; inferred_offset = None; } - let insert_text = insert_text - .or_else(|| x.insert_text.clone()) - .unwrap_or_else(|| x.label.clone()); + let specified_insert_text = x.insert_text.as_ref().unwrap_or(&x.label); + let eventual_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, + }) + .unwrap_or(specified_insert_text); fn completion_entry(insert_text: &str, on_select: &str, menu: &str) -> String { editor_quote(&format!( @@ -212,16 +212,19 @@ { lazy_static! { static ref SNIPPET_TABSTOP_RE: Regex = Regex::new(r"\$(?P<i>\d+)").unwrap(); + // { static ref SNIPPET_PLACEHOLDER_RE: Regex = Regex::new(r"\$\{(?P<i>\d+):?(?P<placeholder>[^}]+)\}").unwrap(); + // { static ref SNIPPET_ESCAPED_METACHARACTERS_RE: Regex = Regex::new(r"\\([$}\\,|])").unwrap(); } - let mut snippet = insert_text; + let mut snippet = eventual_insert_text.to_string(); if !snippet.contains("$0") && !snippet.contains("${0") { snippet += "$0"; } - let insert_text = SNIPPET_TABSTOP_RE.replace_all(&snippet, ""); + let insert_text = specified_insert_text; + let insert_text = SNIPPET_TABSTOP_RE.replace_all(insert_text, ""); let insert_text = SNIPPET_PLACEHOLDER_RE.replace_all(&insert_text, "$placeholder"); // Unescape metacharacters. let insert_text = SNIPPET_ESCAPED_METACHARACTERS_RE.replace_all(&insert_text, "$1"); @@ -239,26 +242,17 @@ // 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 { + let (insert_text, on_select) = if specified_filter_text != eventual_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")) + editor_quote(&(eventual_insert_text.to_string() + "$0")) ); (specified_filter_text, on_select) } else { - (&insert_text, on_select) + (eventual_insert_text, on_select) }; completion_entry(insert_text, &on_select, &entry) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/src/language_features/hover.rs new/kakoune-lsp-17.1.1/src/language_features/hover.rs --- old/kakoune-lsp-17.0.1/src/language_features/hover.rs 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/src/language_features/hover.rs 2024-06-27 10:42:05.000000000 +0200 @@ -373,5 +373,5 @@ ); ctx.exec(meta, command); - let _ = std::fs::write(&fifo, &contents); + let _ = std::fs::write(&fifo, contents); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/src/language_server_transport.rs new/kakoune-lsp-17.1.1/src/language_server_transport.rs --- old/kakoune-lsp-17.0.1/src/language_server_transport.rs 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/src/language_server_transport.rs 2024-06-27 10:42:05.000000000 +0200 @@ -3,7 +3,7 @@ use crossbeam_channel::{Receiver, Sender, TryRecvError}; use jsonrpc_core::{self, Call, Output}; use std::collections::HashMap; -use std::io::{self, BufRead, BufReader, BufWriter, Error, ErrorKind, Read, Write}; +use std::io::{self, BufRead, BufReader, BufWriter, Error, ErrorKind, Write}; use std::process::{Command, Stdio}; pub struct LanguageServerTransport { @@ -55,21 +55,22 @@ let errors = Worker::spawn( "Language server errors", channel_capacity, - move |receiver, _| loop { + move |receiver, _| { if let Err(TryRecvError::Disconnected) = receiver.try_recv() { return; } - let mut buf = String::new(); - match stderr.read_to_string(&mut buf) { - Ok(_) => { - if buf.is_empty() { + let mut line = String::new(); + loop { + line.clear(); + match stderr.read_line(&mut line) { + Ok(0) => return, + Ok(_n) => { + error!("Language server stderr: {}", line.trim_end_matches('\n')); + } + Err(e) => { + error!("Failed to read from language server stderr: {}", e); return; } - error!("Language server error: {}", buf); - } - Err(e) => { - error!("Failed to read from language server stderr: {}", e); - return; } } }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/src/main.rs new/kakoune-lsp-17.1.1/src/main.rs --- old/kakoune-lsp-17.0.1/src/main.rs 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/src/main.rs 2024-06-27 10:42:05.000000000 +0200 @@ -189,7 +189,7 @@ } } cfg.language_server - .insert(language.command.clone(), language); + .insert(format!("{}:{}", language_id, language.command), language); } } Ok(cfg) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/src/markup.rs new/kakoune-lsp-17.1.1/src/markup.rs --- old/kakoune-lsp-17.0.1/src/markup.rs 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/src/markup.rs 2024-06-27 10:42:05.000000000 +0200 @@ -35,6 +35,8 @@ let mut is_codeblock = false; // State to indicate a block quote let mut is_blockquote = false; + // State to indicate a table + let mut is_table = false; // State to indicate that at least one text line in a block quote // has been emitted let mut has_blockquote_text = false; @@ -181,6 +183,7 @@ tag => warn!("Unsupported Markdown tag: {:?}", tag), }, Event::Text(text) => { + is_table = text.starts_with('|'); if is_blockquote { has_blockquote_text = true; markup.push_str("> ") @@ -208,7 +211,7 @@ // Soft breaks should be kept in `<pre>`-style blocks. // Anywhere else, let the renderer handle line breaks. Event::SoftBreak => { - if is_blockquote || is_codeblock { + if is_blockquote || is_codeblock || is_table { markup.push('\n') } else { markup.push(' ') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/src/types.rs new/kakoune-lsp-17.1.1/src/types.rs --- old/kakoune-lsp-17.0.1/src/types.rs 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/src/types.rs 2024-06-27 10:42:05.000000000 +0200 @@ -252,6 +252,8 @@ pub struct CodeActionsParams { pub selection_desc: String, pub perform_code_action: bool, + pub auto_single: bool, + pub only: Option<String>, pub code_action_pattern: Option<String>, } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/src/workspace.rs new/kakoune-lsp-17.1.1/src/workspace.rs --- old/kakoune-lsp-17.0.1/src/workspace.rs 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/src/workspace.rs 2024-06-27 10:42:05.000000000 +0200 @@ -46,7 +46,8 @@ Value::Object(explode_string_table(raw_settings)) } else { let server = ctx.config.language_server.get(server_name).unwrap(); - configured_section(ctx, server_name, server.settings.as_ref()).unwrap_or_default() + configured_section(ctx, server_name, server.settings.as_ref()) + .unwrap_or_else(|| Value::Object(serde_json::Map::new())) } }); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/test/gopls-code-action-sync.sh new/kakoune-lsp-17.1.1/test/gopls-code-action-sync.sh --- old/kakoune-lsp-17.0.1/test/gopls-code-action-sync.sh 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/test/gopls-code-action-sync.sh 1970-01-01 01:00:00.000000000 +0100 @@ -1,28 +0,0 @@ -#!/bin/sh - -# REQUIRES: command -v gopls - -. test/lib.sh - -cat > main.go << EOF -package main - -import "os" - -func main() {} -EOF - -test_tmux_kak_start 'edit main.go' - -test_sleep -test_tmux send-keys ':lsp-code-action-sync Organize.Imports' Enter -test_sleep -test_tmux capture-pane -p | sed 3q -# CHECK: package main -# CHECK: -# CHECK: func main() {} - -test_tmux send-keys ':lsp-code-action-sync Organize.Imports' Enter -test_sleep -test_tmux capture-pane -p | sed -n '$p' -# CHECK: lsp-code-action: no matching action available{{.*}} 1 sel - client0@[session] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/test/gopls-code-actions-sync.sh new/kakoune-lsp-17.1.1/test/gopls-code-actions-sync.sh --- old/kakoune-lsp-17.0.1/test/gopls-code-actions-sync.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/kakoune-lsp-17.1.1/test/gopls-code-actions-sync.sh 2024-06-27 10:42:05.000000000 +0200 @@ -0,0 +1,28 @@ +#!/bin/sh + +# REQUIRES: command -v gopls + +. test/lib.sh + +cat > main.go << EOF +package main + +import "os" + +func main() {} +EOF + +test_tmux_kak_start 'edit main.go' + +test_sleep +test_tmux send-keys ':lsp-code-actions-sync source.organizeImports' Enter +test_sleep +test_tmux capture-pane -p | sed 3q +# CHECK: package main +# CHECK: +# CHECK: func main() {} + +test_tmux send-keys ':lsp-code-actions-sync source.organizeImports' Enter +test_sleep +test_tmux capture-pane -p | sed -n '$p' +# CHECK: lsp-code-actions: no matching action available{{.*}} 1 sel - client0@[session] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/test/gopls-format-on-save.sh new/kakoune-lsp-17.1.1/test/gopls-format-on-save.sh --- old/kakoune-lsp-17.0.1/test/gopls-format-on-save.sh 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/test/gopls-format-on-save.sh 2024-06-27 10:42:05.000000000 +0200 @@ -6,7 +6,7 @@ cat >> .config/kak/kakrc << EOF hook global BufWritePre .*[.]go %{ - try %{ lsp-code-action-sync '^Organize Imports$' } + try %{ lsp-code-actions-sync source.organizeImports } lsp-formatting-sync } EOF diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kakoune-lsp-17.0.1/test/lib.sh new/kakoune-lsp-17.1.1/test/lib.sh --- old/kakoune-lsp-17.0.1/test/lib.sh 2024-04-06 23:10:50.000000000 +0200 +++ new/kakoune-lsp-17.1.1/test/lib.sh 2024-06-27 10:42:05.000000000 +0200 @@ -101,6 +101,7 @@ test_sleep_until "! kak -c $test_kak_session -ui dummy -e quit >/dev/null 2>&1" sleep .1 test_tmux kill-server >/dev/null 2>&1 + sleep .1 rm -rf "$HOME" } trap test_cleanup EXIT ++++++ vendor.tar.zst ++++++ /work/SRC/openSUSE:Factory/kak-lsp/vendor.tar.zst /work/SRC/openSUSE:Factory/.kak-lsp.new.17339/vendor.tar.zst differ: char 7, line 1
