Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting to disable in comments #8 #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion proto/exa/language_server_pb/language_server.proto
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,11 @@ message Document {
Range visible_range = 9;
}

// Next ID: 3, Previous field: insert_spaces.
// Next ID: 4, Previous field: disable_autocomplete_in_comments.
message EditorOptions {
uint64 tab_size = 1;
bool insert_spaces = 2;
bool disable_autocomplete_in_comments = 3;
}

enum CodeiumState {
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/com/codeium/intellij/EditorManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package com.codeium.intellij

import com.codeium.intellij.auth.CodeiumAuthService
import com.codeium.intellij.language_server.LanguageServerService
import com.codeium.intellij.settings.AppSettingsState
import com.codeium.intellij.statusbar.CodeiumStatusService
import com.intellij.codeInsight.lookup.LookupManager
import com.intellij.injected.editor.VirtualFileWindow
Expand Down Expand Up @@ -240,6 +241,7 @@ class EditorManager {
return CodeiumCommon.EditorOptions.newBuilder()
.setInsertSpaces(!settings.isUseTabCharacter(editor.project))
.setTabSize(settings.getTabSize(editor.project).toLong())
.setDisableAutocompleteInComments(!AppSettingsState.instance.enableInComments)
.build()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,26 @@ class AppSettingsConfigurable : Configurable {
override fun isModified(): Boolean {
val settings: AppSettingsState = AppSettingsState.instance
return (codeiumSettingsComponent?.chatInlayEnabled != settings.chatInlayEnabled ||
codeiumSettingsComponent?.indexingEnabled != settings.indexingEnabled ||
codeiumSettingsComponent?.indexingMaxFileCount != settings.indexingMaxFileCount)
codeiumSettingsComponent?.indexingEnabled != settings.indexingEnabled ||
codeiumSettingsComponent?.indexingMaxFileCount != settings.indexingMaxFileCount ||
codeiumSettingsComponent?.enableInComments != settings.enableInComments
)
}

override fun apply() {
val settings: AppSettingsState = AppSettingsState.instance
settings.chatInlayEnabled = codeiumSettingsComponent!!.chatInlayEnabled
settings.indexingEnabled = codeiumSettingsComponent!!.indexingEnabled
settings.indexingMaxFileCount = codeiumSettingsComponent!!.indexingMaxFileCount
settings.enableInComments = codeiumSettingsComponent!!.enableInComments
}

override fun reset() {
val settings: AppSettingsState = AppSettingsState.instance
codeiumSettingsComponent!!.chatInlayEnabled = settings.chatInlayEnabled
codeiumSettingsComponent!!.indexingEnabled = settings.indexingEnabled
codeiumSettingsComponent!!.indexingMaxFileCount = settings.indexingMaxFileCount
codeiumSettingsComponent!!.enableInComments = settings.enableInComments
}

override fun disposeUIResources() {
Expand All @@ -66,18 +70,22 @@ class AppSettingsConfigurable : Configurable {
private val chatInlayEnabledCheckBox = JBCheckBox("Enable Chat Inlay Hints ")
private val indexingEnabledCheckBox = JBCheckBox("Enable Codeium Indexing (Requires Reload)")
private val indexingMaxFileCountTextField = JBTextField("5000")
private val enableInCommentsCheckBox = JBCheckBox("If true, Codeium will provide autocomplete suggestions in comments.")

init {
indexingMaxFileCountTextField.setToolTipText(
"If indexing is enabled, we will only attempt to index workspaces that have up to this many files. This file count ignores .gitignore and binary files. Raising this limit from default may lead to performance issues. Values 0 or below will be treated as unlimited.")
"If indexing is enabled, we will only attempt to index workspaces that have up to this many files. This file count ignores .gitignore and binary files. Raising this limit from default may lead to performance issues. Values 0 or below will be treated as unlimited."
)
panel =
FormBuilder.createFormBuilder()
.addComponent(chatInlayEnabledCheckBox, 1)
.addComponent(indexingEnabledCheckBox, 1)
.addLabeledComponent(
"Indexing Max Workspace Size (File Count)", indexingMaxFileCountTextField, 1)
.addComponentFillVertically(JPanel(), 0)
.getPanel()
FormBuilder.createFormBuilder()
.addComponent(chatInlayEnabledCheckBox, 1)
.addComponent(indexingEnabledCheckBox, 1)
.addLabeledComponent(
"Indexing Max Workspace Size (File Count)", indexingMaxFileCountTextField, 1
)
.addComponent(enableInCommentsCheckBox, 1)
.addComponentFillVertically(JPanel(), 0)
.getPanel()
}

val preferredFocusedComponent: JComponent
Expand All @@ -98,5 +106,10 @@ class AppSettingsConfigurable : Configurable {
set(newValue) {
indexingMaxFileCountTextField.setText(newValue.toString())
}
var enableInComments: Boolean
get() = enableInCommentsCheckBox.isSelected
set(newStatus) {
enableInCommentsCheckBox.isSelected = newStatus
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class AppSettingsState : PersistentStateComponent<AppSettingsState> {
var chatInlayEnabled = true
var indexingEnabled = false
var indexingMaxFileCount = 5000
var enableInComments = false

@Nullable
override fun getState(): AppSettingsState {
Expand Down