Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. How to configure QTCreator to use bash-language-server?
Forum Updated to NodeBB v4.3 + New Features

How to configure QTCreator to use bash-language-server?

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
2 Posts 2 Posters 64 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tyler Shellberg
    wrote last edited by Tyler Shellberg
    #1

    I'm using QTCreator 17.02 on MSYS2.
    I need to edit some Bash scripts, and would like to use tooling like shfmt, ShellCheck, etc - all from within QTCreator.
    Luckily, bash-language-server (https://github.com/bash-lsp/bash-language-server) exists to solve this.

    Unfortunately, I cannot seem to get this to work. When I open a bash file, QTCreator reports:

    LanguageClient Bash Language Server: Unexpectedly finished.

    The language server itself seems to be implemented as a shell script that has a special case for MSYS:

    #!/bin/sh
    basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
    
    case `uname` in
        *CYGWIN*|*MINGW*|*MSYS*)
            if command -v cygpath > /dev/null 2>&1; then
                basedir=`cygpath -w "$basedir"`
            fi
        ;;
    esac
    
    if [ -x "$basedir/node" ]; then
      exec "$basedir/node"  "$basedir/../lib/node_modules/bash-language-server/out/cli.js" "$@"
    else 
      exec node  "$basedir/../lib/node_modules/bash-language-server/out/cli.js" "$@"
    fi
    
    

    So at the moment in QTCreator, I'm accessing the language server as follows:

    • Startup Behavior: Requires an Open File
    • Initialization options: (empty)
    • Executable: C:\msys64\usr\bin\sh.exe
    • Arguments: C:\msys64\ucrt64\bin\bash-language-server

    I'm not really sure how to fix this. It's possible this language server just isn't compatible with QTCreator?

    I also tried running the server with "start" before trying to open QTCreator, but that did not help.

    I've also tried setting it to use C:/msys64/ucrt64/bin/bash-language-server.cmd, with no arguments - but I have the same error.

    EDIT: I tried this on a Rocky 9 machine as well, and here I do get some useful output:

    kf.syntaxhighlighting: Unable to resolve external include rule for definition "reStructuredText" in "Bash"
    qtc.languageserverprotocol.parse: Unexpected header line: "Usage:\n"
    qtc.languageserverprotocol.parse: Unexpected header line: "  bash-language-server start             Start listening on stdin/stdout\n"
    qtc.languageserverprotocol.parse: Unexpected header line: "  bash-language-server -h, --help        Display this help and exit\n"
    qtc.languageserverprotocol.parse: Unexpected header line: "  bash-language-server -v, --version     Print the version and exit\n"
    qtc.languageserverprotocol.parse: Unexpected header line: "\n"
    qtc.languageserverprotocol.parse: Unexpected header line: "Environment variables:\n"
    qtc.languageserverprotocol.parse: Unexpected header field "BASH_IDE_LOG_LEVEL                     Set the log level (default" in "  BASH_IDE_LOG_LEVEL                     Set the log level (default: info)\n"
    qtc.languageserverprotocol.parse: Unexpected header line: "\n"
    qtc.languageserverprotocol.parse: Unexpected header field "Further documentation" in "Further documentation: https://github.com/bash-lsp/bash-language-server\n"
    

    So it looks like the issue is that it's interacting with the language server in the wrong way? That's the output I would expect if I just ran the executable with no arguments. I'm not sure how to resolve that though.

    1 Reply Last reply
    0
    • aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote last edited by aha_1980
      #2

      Hi @Tyler-Shellberg,

      on my Ubuntu Linux 24 I installed the bash-language-server with snap and then setup the language client as follows:

      image.png

      and this works for me. If you have to set sh.exe as executable, then please try to add start as argument.

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved