PyCharm with LSP

Short version:

  1. Install Robot Framework 3.2.1: pip install -U robotframework
  2. Install Robot Framework LSP server: pip install -U robotframework-lsp
  3. Install LSP Support Plugin to PyCharm: https://plugins.jetbrains.com/plugin/10209-lsp-support
  4. Add Server Definitions to Language Server Protocol (Executable, robot, )
  5. Download robot.tmlanguage
  6. Add path to tmLanguage file to Editor > TextMate Bundles in Pycharm Preferences.

Originally posted by @René in Slack

1 Like

Longer version:

  1. Install Robot Framework 3.2.1: pip install -U robotframework
  2. Install Robot Framework LSP server: pip install -U robotframework-lsp
  3. Install LSP Support Plugin in PyCharm*
    image
  4. Add Server Definition to LSP Support
    Preferences > Languages & Frameworks > Language Server Protocol > Server Definitions
    Select Executable and select the robotframework-ls executable in the python bin or scripts folder.
    As alternative you could use the path to python executable in Path field and -u <path to repo>/src/robotframework_ls in the Args field.On windows use \ instead of / in these paths
  5. Download TMLanguage definition
    The TMLanguage is the definition file to get s proper syntax highlighting. This is completely independent from LSP and code completion itself.
    Download this file and put it in a directory where it can stay.
  6. Add robotframework.tmLanguage to TextMate Bundles
    Add the folder where the tmLanguage file is saved in. Not the file directly
  7. Restart PyCharm and enjoy

:robot: Updated new Syntax Highlighting:

robot.tmLanguage (33.2 KB)

1 Like

Just as an information.
Code Completion seems to be case sensitive in PyCharm at the moment.

So you have to type in Wait instead of wait to get suggestions for all Wait-Keywords

1 Like

Worth mentioning is that if you are trying to run lsp on Mac, lsp might be failing because it tries to open a lot of files and and default 256 open filehandles is running out… To fix this temporarily, ulimit -n 4096 on shell might help.

2 Likes

Code completion seems to only work with UPPERCASE even if the completed statement is automatically lower case after being completed.

Hi,

Can anyone help me out with adding the server definition to LSP Support in Windows 10?

There is dedicated RF plugin for PyCharm robotframework-lsp/robotframework-intellij at master · robocorp/robotframework-lsp · GitHub

It’s currently in beta stage but feedback and bug reports are welcomed.

Hi @aaltat, on step #4 i am getting next error :
Can’t start server, please check settings
Cannot run program “C:\Python36\Lib\site-packages\robotframework_ls”:
CreateProcess error=5, Access is denied

Is this related to my permissions on the C drive?

Yes it’s an access problem

Hi René

I have some issue with the Reformat code.

Here’s my sample

Invalid Login with Invalid User
[Setup]    Start Session    ${BROWSER_NAME}    ${TEST_NAME}    ${BUILD_NAME}
Open Login Page

Login As Invalid User

Is Login Error Displayed
[Teardown]    End Session    ${TEST_STATUS}

After running Reformat code it became

Invalid Login with Invalid User
[Setup]    Start Session    ${BROWSER_NAME}    ${TEST_NAME}    ${BUILD_NAME}
Open Login Page

Login As Invalid User

Is Login Error Displayed
[Teardown]    End Session    ${TEST_STATUS
}

Notice the last } went to new line