Neovim for Beginners — Kotlin

Configure Neovim for Kotlin programming.

alpha2phi
3 min readJun 9, 2022

--

Neovim for Beginners — Kotlin

In this article, let’s configure Neovim for the Kotlin programming language.

This article is part of the Neovim for Beginners series.

The Neovim configuration files can be found in this repository.

Getting Started

Kotlin command-line compiler

We need to install the Kotlin compiler. For Unix-based systems, such as macOS, Linux, Cygwin, FreeBSD, and Solaris, we can use SDKMAN following the installation guide.

sdk install kotlin

Create a Kotlin Project

To make it easy for demonstration purposes, instead of using an Android application, we will create a Kotlin application using Gradle.

$ gradle init

Select type of project to generate:
1: basic
2: application
3: library
4: Gradle plugin
Enter selection (default: basic) [1..4] 2

Select implementation language:
1: C++
2: Groovy
3: Java
4: Kotlin
5: Scala
6: Swift
Enter selection (default: Java) [1..6] 4

Select build script DSL:
1: Groovy
2: Kotlin
Enter selection (default: Groovy) [1..2] 1

Project name (default: demo):
Source package (default: demo):


BUILD SUCCESSFUL
2 actionable tasks: 2 executed

The project structure of the sample application is shown below.

Sample Kotlin Project

Type “./gradlew build” to build the application, and “./gradlew run” to run it.

Syntax Highlighting

We already installed nvim-treesitter and it supports syntax highlighting for Kotlin.

We can use the :TSInstallInfo command to check if the language is installed.

Treesitter Installed Languages

Alternatively, we can install the kotlin-vim plugin.

Language Server

--

--

alpha2phi

Software engineer, Data Science and ML practitioner.