1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-01-02 19:42:50 +01:00

Add more compatibility methods

This commit is contained in:
Alex Plate 2022-07-01 15:55:07 +03:00
parent fdb09a8f1f
commit a0dc7a792f
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
2 changed files with 23 additions and 0 deletions
src/main/java/com/maddyhome/idea/vim/option
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api

View File

@ -18,12 +18,23 @@
package com.maddyhome.idea.vim.option
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.options.OptionConstants
import com.maddyhome.idea.vim.options.OptionConstants.Companion.ignorecaseName
import com.maddyhome.idea.vim.options.OptionConstants.Companion.smartcaseName
import com.maddyhome.idea.vim.options.OptionScope
import com.maddyhome.idea.vim.options.ToggleOption
import com.maddyhome.idea.vim.options.helpers.KeywordOptionHelper
import com.maddyhome.idea.vim.vimscript.services.IjVimOptionService
/**
* COMPATIBILITY-LAYER: Added a class and package
*/
object OptionsManager {
val ignorecase: ToggleOption
get() = (injector.optionService as IjVimOptionService).getRawOption(ignorecaseName) as ToggleOption
val smartcase: ToggleOption
get() = (injector.optionService as IjVimOptionService).getRawOption(smartcaseName) as ToggleOption
val iskeyword: KeywordOption
get() = KeywordOption(KeywordOptionHelper)
}
@ -33,3 +44,11 @@ class KeywordOption(val helper: KeywordOptionHelper) {
return helper.toRegex()
}
}
object StrictMode {
fun fail(message: String) {
if (injector.optionService.isSet(OptionScope.GLOBAL, OptionConstants.ideastrictmodeName)) {
error(message)
}
}
}

View File

@ -359,6 +359,10 @@ abstract class VimOptionServiceBase : OptionService {
options.get(optionName)!!.removeOptionChangeListener(listener)
}
fun getRawOption(key: String): Option<out VimDataType>? {
return options.get(key)
}
private fun castToVimDataType(value: String, optionName: String, token: String): VimDataType {
val option = options.get(optionName) ?: throw ExException("E518: Unknown option: $token")
return when (option) {