Git Product home page Git Product logo

kotlin-vim's Introduction

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!

kotlin-vim's People

Contributors

benjaminjkraft avatar chaoren avatar chocolateboy avatar cskr avatar francis36012 avatar gavocanov avatar henrebotha avatar justfortherec avatar matejkastak avatar sciencesakura avatar snape3058 avatar tplunket avatar udalov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kotlin-vim's Issues

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

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

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.

Pathogen command slightly incorrect in README.md

I think this should probably be:

$ git clone https://github.com/udalov/kotlin-vim ~/.vim/bundle/kotlin-vim

otherwise it will attempt to clone into the ~/.vim/bundle directory directly, which fails if there are already other bundles installed.

Syntax highlighting doesn't work with Vundle

I've installed the plugin using Vundle
Plugin 'udalov/kotlin-vim'

Then I've made sure to run PluginInstall. Everything went fine and I've restarted the editor several times. But I get not syntax highlighting at all.

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

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.

Code completion

Let's have Kotlin completions!!! 😄

I've forked this repo to start working on completions, but it would be nice to collaborate on a feature branch here. I've never written a Vim plugin, so I'm using this as a guide: https://github.com/artur-shaik/vim-javacomplete2

They're using an AST parser, which Kotlin provides as an embeddable dependency (I've used it here: https://github.com/notion/kotlin-format). If this doesn't fit into the scope of this repo, I can close this issue and start a new project.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.