Skip to content

Latest commit

 

History

History
99 lines (70 loc) · 4.07 KB

EDITORS.md

File metadata and controls

99 lines (70 loc) · 4.07 KB

Editor Integration

Visual Studio Code

See vscode-kotlin or install the extension from the marketplace.

Sublime Text

See lsp-kotlin.

Emacs

using lsp-mode

There are two ways of setting up the language server with lsp-mode:

  • Add the language server executable to your PATH. This is useful for development and for always using the latest version from the main-branch.
  • Let lsp-mode download the server for you (kotlin-ls). This will use the latest release.

Run/debug code lenses

If you use dap-mode, you can set (setq lsp-kotlin-debug-adapter-enabled t) to enable the debug adapter. You will need to have Kotlin Debug Adapter on your system. A simple configuration of dap-mode for Kotlin may look like:

(require 'dap-kotlin)
(setq lsp-kotlin-debug-adapter-enabled t)
;; replace the path below to the path to your Kotlin Debug Adapter
(setq lsp-kotlin-debug-adapter-path "/path/to/kotlin-debug-adapter")

Then you can activate lsp-kotlin-lens-mode to see the Run/Debug code lenses at your main-functions.

Override members (e.g, toString and equals)

The language server provides a custom protocol extension for finding overridable members of a class (variables and methods). lsp-mode provides a function that uses this called lsp-kotlin-implement-member. You can run it while hovering a class name, and you will get a menu with all available overridable members. (protip: Bind this function to a key!). If you have Helm or Ivy installed, one of them will be utilized.

Vim

using LanguageClient-neovim

Add the language server to your PATH and include the following configuration in your .vimrc:

autocmd BufReadPost *.kt setlocal filetype=kotlin

let g:LanguageClient_serverCommands = {
    \ 'kotlin': ["kotlin-language-server"],
    \ }

using coc.nvim

Add the following to your coc-settings.json file:

{
    "languageserver": {
        "kotlin": {
            "command": "[path to cloned language server]/server/build/install/server/bin/kotlin-language-server",
            "filetypes": ["kotlin"]
        }
    }
}

Note that you may need to substitute kotlin-language-server with kotlin-language-server.bat on Windows.
You should also note, that you need a syntax highlighter like udalov/kotlin-vim or sheerun/vim-polyglot to work well with coc.

Neovim

Using Neovim's nvim-lspconfig, register the language server using the following.

require'lspconfig'.kotlin_language_server.setup{}

If desired, you can also pass in your own defined options to the setup function.

require'lspconfig'.kotlin_language_server.setup{
    on_attach = on_attach,
    flags = lsp_flags,
    capabilities = capabilities,
}

Monaco Editor

See kotlin-monaco-language-server.

Other Editors

Install a Language Server Protocol client for your tool. Then invoke the language server executable in a client-specific way.

The server can be launched in three modes:

  • Stdio (the default mode)
    • The language server uses the standard streams for JSON-RPC communication
  • TCP Server
    • The language server starts a server socket and listens on --tcpServerPort
  • TCP Client
    • The language server tries to connect to --tcpClientHost and --tcpClientPort

The mode is automatically determined by the arguments provided to the language server.