Kotlin plugin for Vim. Featuring: syntax highlighting, basic indentation, Syntastic support

Overview

kotlin-vim

Installation

If you use Vim 8 or later, the recommended way is using Vim's built-in package manager:

git clone https://github.com/udalov/kotlin-vim.git ~/.vim/pack/plugins/start/kotlin-vim

Other plugin managers:

  • Vundle
    • add Plugin 'udalov/kotlin-vim' to your ~/.vimrc and run PluginInstall.
  • Pathogen
    • git clone https://github.com/udalov/kotlin-vim ~/.vim/bundle/kotlin-vim

Manual (for older versions of Vim)

  1. mkdir -p ~/.vim/{syntax,indent,ftdetect,ftplugin}
  2. cp syntax/kotlin.vim ~/.vim/syntax/kotlin.vim
  3. cp indent/kotlin.vim ~/.vim/indent/kotlin.vim
  4. cp ftdetect/kotlin.vim ~/.vim/ftdetect/kotlin.vim
  5. cp ftplugin/kotlin.vim ~/.vim/ftplugin/kotlin.vim
  6. If you use Syntastic: cp -r syntax_checkers/kotlin ~/.vim/syntax_checkers/
  7. Restart Vim
Enjoy!
Comments
  • Plugin fails without Syntastic

    Plugin fails without Syntastic

    I just installed your plugin and started vim with a Kotlin file. First thing happening is this:

    $ vim build.gradle.kts
    Fehler beim Ausführen von "~/.vim/plugin/kotlin-vim/syntax_checkers/kotlin/kotlinc.vim":
    Zeile   99:
    E121: Undefinierte Variable: g:SyntasticRegistry
    Betätigen Sie die EINGABETASTE oder geben Sie einen Befehl ein
    
    opened by Vampire 5
  • vimlint, add operators, use hi def link

    vimlint, add operators, use hi def link

    Using hi def let's user override stuff, in color themes etc., I'm a heavy user of that and it was not working for kotlin.

    Also current syntax is commonly defined at the end.

    " to ' to make vim linter happy :)

    Hope this helps and thnx for Kotlin!

    opened by gavocanov 5
  • Add rest of core Kotlin types

    Add rest of core Kotlin types

    As listed here: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/index.html

    Fixes #12.

    Realized after I made these changes that this conflicts with #32, which also adds some missing types but not all of these...

    opened by sjrct 4
  • Fix nested comments

    Fix nested comments

    The whole of the following program is highlighted as a comment for me in vim 7.4 (Ubuntu 14.04):

    /* Hello, world! */
    
    fun main(args: Array<String>) {
        println("Hello, world!")
    }
    

    The problem appears to be that /* is matched as the start of the inner/contained region rather than the start of the outer/containing region i.e. this works:

    /* */ */
    
    fun main(args: Array<String>) {
        println("Hello, world!")
    }
    

    The documentation doesn't help much, but using a matchgroup (and not giving it the same name as the region) seems to solve the problem, and even handles /*/**/*/ and /* */* (via) correctly.

    I also updated the README to include Vundle and Pathogen installation instructions.

    opened by chocolateboy 4
  • Causing error on Writting kt file [ command :w ]

    Causing error on Writting kt file [ command :w ]

    This may not be an issue but a configurations error instead, I'm new to vim, I already searched for related solutions to my issue but I find none. I directed here to find some answers.

    Error detected while processing function <SNR>58_BufWritePostHook[3]..<SNR>58_UpdateErrors[8]..<SNR>58_CacheErrors[27]
    ..197[1]..196[3]..SyntaxCheckers_kotlin_kotlinc_GetLocList:
    line   22:
    E117: Unknown function: syntastic#util#tmpdir
    E15: Invalid expression: syntastic#util#tmpdir()
    Error detected while processing function <SNR>58_BufWritePostHook[3]..<SNR>58_UpdateErrors[8]..<SNR>58_CacheErrors:
    line   27:
    E170: Missing :endfor
    Error detected while processing function <SNR>58_BufWritePostHook[3]..<SNR>58_UpdateErrors:
    line    8:
    E171: Missing :endif
    
    opened by blackmo18 3
  • Add ftplugin to set comment syntax

    Add ftplugin to set comment syntax

    The plugin as it stands does not set the comment syntax, which means various Vim features acting on comments don't work properly.

    This adds settings for comment syntax when editing Kotlin files.

    opened by henrebotha 3
  • Highlight function, class, interface, type definitions

    Highlight function, class, interface, type definitions

    Pictures say more than words, so here is one.

    Function/constructor calls aren’t highlighted yet. I would like to add that as well, but that feels like a separate issue to me, and I don’t know if you even want it.

    opened by kageru 2
  • Add three-piece comments declaration

    Add three-piece comments declaration

    This allows us to have C-style comments in kotlin, a la:

    /**
     * Start of comment
     *
     * More comment
     */
    

    and have vim autoindent them (according to your formatoptions setting, that is). I copied the setting from the builtin ftplugin for JavaScript, since they have equivalent comment syntax.

    opened by benjaminjkraft 2
  • send to upstream Vim

    send to upstream Vim

    Vim 8.1 does not detect *.kt nor *.kts files as kotlin.

    Would you consider sending this plugin upstream to https://github.com/vim/vim/ ? All that's needed is for you (the author) to create an issue at https://github.com/vim/vim/ , point to this repo and say that you are the author and you would like it to be included.

    opened by justinmk 2
  • Update number pattern with underscore separators

    Update number pattern with underscore separators

    As far as I know, the number constants like '1_000_000', '0xFF_EC_DE_5E' and '0b11010010_01101001_10010100_10010010' are also valid, so I updated these three patterns. By the way, the pattern for binary numbers should accept 0 and 1 only, I corrected it as well.

    opened by Snape3058 2
  • Autoindentations: Ignoring comments option's leading spaces.

    Autoindentations: Ignoring comments option's leading spaces.

    I've come across a bug in the indent/kotlin.vim file. The way it currently handles indentations does not account for C style/Javadoc comments like so:

    /**
     * Comment
     * Stuff
     */
    fun doSomething(): Int {
        
    }
    

    The problem:

    When using the formatoptions r flag, Vim allows auto placement of comment blocks with a return line. For example, in normal Java, this will look like:

    /**
    

    Then pressing enter will give:

    /**
     *
    

    With the default configuration of the comments option in Vim. Kotlin's current indentation vim script ignores these settings, and places:

    /**
    *
    

    This cannot be fixed unless the indentation script is modified. My current work around has been to remove the indentation script.

    opened by CrystalSplitter 2
  • Could the syntax files be bundled with vim?

    Could the syntax files be bundled with vim?

    It would be great if vim could give you basic Kotlin syntax highlighting out-of-the-box. Any interest in sending a patch to add syntax into https://github.com/vim/vim/tree/master/runtime/syntax?

    opened by dbarnett 3
  • Backslash escapes shouldn't be recognized in raw strings

    Backslash escapes shouldn't be recognized in raw strings

    Triple-quoted strings in Kotlin do not do any escape processing so backslash-character should not be interpreted as an escape sequence.

    E.g. my TeamCity config contains lines such as

            scriptContent = """tools\bin\make -C workdir myapp"""
    

    ...and the backslash-b is highlighted as if it is valid while backslash-m is highlighted as an error. Neither of these should be highlight.

    I believe that the fix is to simply remove the ,ktSpecialChar,ktSpecialCharError bit from the end of the line in syntax/kotlin.vim for ktString start='"""' but I'm not sure if that's entirely correct.

    I reference the information about "raw strings" on https://devtut.github.io/kotlin/strings.html#string-literals

    opened by tplunket 0
  • Feature Request: Highlight Function Names (and/or names of classes, interfaces, etc.)

    Feature Request: Highlight Function Names (and/or names of classes, interfaces, etc.)

    Function name highlighting is implemented in both rust.vim and vim-cpp-enhanced-highlight, and rust.vim has highlighting for names of structs too, which is really nice (would be highlighting of class/interface/etc. names here). I'm not sure if this is wanted in this particular plugin, but I figured I'd throw it out there since it helps readability and makes things look nicer IMHO.

    This could be implemented multiple ways too. For example, python-syntax only highlights the names of functions when they are defined, but not called (as far as I've noticed). I think always highlighting function names (on both calls and definitions) looks nicer, but of course opinions on this will vary.

    opened by smolck 4
  • Q: Tweak makeprg

    Q: Tweak makeprg

    How do you feel about adding support for appropriate makeprg into this plugin? Something like this should do:

    :setlocal makeprg=java\ -cp\ .:/usr/local/Cellar/kotlin/1.3.10/libexec/lib/kotlin-stdlib.jar\ %:r:gs?^.?\\u&?Kt
    

    ( % filename :r remove extension gs?^.?\\u&? - capitalise first letter (hello - Hello) - same as in /^./\u&/gs Kt - add to the end )

    This will cover scripts without specified package: :!java -cp .:/usr/local/Cellar/kotlin/1.3.10/libexec/lib/kotlin-stdlib.jar HelloKt

    But sure this can be extended with something like :echo substitute(getline(1), ‘package ‘, ‘’, ‘’).

    I'm not totally clear on how to get kotlin stdlib path. We can try to guess it or require user to set env variable to the kotlin install dir.

    opened by vigilancer 9
  • Autoindent of closing brace doesn't work after a block comment

    Autoindent of closing brace doesn't work after a block comment

    fun foo() {
        /*
        println()
        */
        <caret>
    

    Press } at the caret position in the source above.

    Expected result:

    fun foo() {
        /*
        println()
        */
    }
    

    Actual result:

    fun foo() {
        /*
        println()
        */
        }
    
    opened by udalov 0
Owner
Alexander Udalov
Alexander Udalov
Basic-Android-Project - A Basic Android Project with proper structure and all necessary dependencies

Basic-Android-Project A Basic Android Project with proper structure and all nece

Ameer Hamza 2 Mar 18, 2022
Scala 3 Standard Library with bracket syntax.

Scala 3 Library with braces Scala adds a terrible new feature, optional braces, which allow use indentation instead of braces. The new syntax is widel

Glavo 10 Dec 30, 2021
A funny project to help you test your BNF syntax

Readme The idea of this project is to implement a BNF expression compiler. We could use BNF to design some syntax like Arithmetic expression. <factor>

Jack Chen 4 Dec 21, 2022
Android Kotlin Fundamentals 01.2: Anatomy of Basic Android Project

Welcome to Android Kotlin Fundamentals 01.2: Anatomy of Basic Android Project ?? Codelab de android para practicar apps Android con Kotlin ?? Homepage

null 0 Oct 23, 2021
Basic RestAPI to practice my skills working with Spring/Kotlin/Gradle

Dining Review API Dining Review API is a basic RestAPI roughly based on the requirements given in a Milestone project in the Building REST APIs with J

Jonas Kuhlo 0 Nov 18, 2021
A basic, incomplete, buggy, far from efficient UI toolkit for Kotlin/Android. An experiment for fun and to learn.

Apex Apex is just a simple proof of concept to demonstrate how easily you can build your own UI Toolkit from scratch. This code base is most likely fu

Romain Guy 79 Sep 7, 2022
A basic, incomplete, buggy, far from efficient UI toolkit for Kotlin/Android. An experiment for fun and to learn.

Apex Apex is just a simple proof of concept to demonstrate how easily you can build your own UI Toolkit from scratch. This code base is most likely fu

Romain Guy 79 Sep 7, 2022
UW Homework: Basic Kotlin

UW Homework: Basic Kotlin This homework is designed to force you to exercise you

Amanda Ki 0 Jan 10, 2022
Kotlin implementation of basic blockchain technology.

kotlin-blockchain Kotlin implementation of basic blockchain technology. Features: Data and storage Mining and block validation Hashing and previous bl

null 2 May 15, 2022
Examples for using Kotlin at a basic level for Android application development.

Kotlin Android Jetpack Basics Ejemplos para usar Kotlin a nivel básico para el desarrollo de aplicaciones Android. Kotlin Android Jetpack Basics Acerc

José Luis González Sánchez 2 Jun 28, 2022
A basic Kotlin implementation of Facebook's memcache lease functionality.

Liftgate Lease A basic Kotlin implementation of Facebook's memcache lease functionality. How it works If the cache key is empty or has been invalidate

null 6 Nov 10, 2022
A simple plugin to patch the memory leak in Kotlin Gradle Plugin 1.5.0

kgp-150-leak-patcher A simple plugin to automatically patch the memory leak in Kotlin Gradle Plugin 1.5.0 in https://youtrack.jetbrains.com/issue/KT-4

Zac Sweers 40 Dec 20, 2021
Basic application that uses Retrofit, Moshi and Coil libraries to parse data from web API

DogAlbum_Api_CodeThrough Basic application that uses Retrofit, Moshi and Coil libraries to parse data from web API This folder contains the completed

Ayana Bando 0 Nov 9, 2021
A basic library that enables easy composition of gesture sequence recognition on a view

GestureSequence A basic library that enables easy composition of gesture sequence recognition on a view. Basic API looks like: // Perform action() whe

Paul Klauser 8 Nov 2, 2022
A basic template ecommerce application with payment integration made using Android Architechture componets

ShopIt ShopIt is a basic template ecommerce application with payment integration(RazorPay), made using Android Architechture componets and Material Co

Apurva Shukla 2 Nov 22, 2021
A single screen app learn in google basic Android Development course.

Project: Lemonade App - Starter Code Starter code for the first independent project for Android Basics in Kotlin Introduction This is the starter code

Kaushal Raj 0 Dec 19, 2022
An open source app which can be used to do basic surveys

SurveyApp This is an open source app which can be used to do basic surveys. It supports multiple question types. For demo please check the releases pa

Dhiraj Uchil 0 Dec 9, 2021
Microservice-arch - Basic micro service architecture using spring boot

Readme 4 applications are created: discovery-service: every application register

Melvin Zottola 1 Jan 8, 2022
Swarup 2 Feb 6, 2022