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:
parent
fdb09a8f1f
commit
a0dc7a792f
src/main/java/com/maddyhome/idea/vim/option
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user