Skip to content

Commit 475c2cf

Browse files
committed
fix(server): Improve language detection
1 parent bcd3e67 commit 475c2cf

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

server/root-handler/lsp/text-document-code-action.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package lsp
22

33
import (
4-
"config-lsp/common"
54
aliases "config-lsp/handlers/aliases/lsp"
65
bitcoinconf "config-lsp/handlers/bitcoin_conf/lsp"
76
hosts "config-lsp/handlers/hosts/lsp"
@@ -21,11 +20,7 @@ func TextDocumentCodeAction(context *glsp.Context, params *protocol.CodeActionPa
2120
if document == nil {
2221
actions := utils.FetchAddLanguageActions(params.TextDocument.URI)
2322

24-
if common.ServerOptions.NoUndetectableErrors {
25-
return actions, nil
26-
} else {
27-
return actions, utils.LanguageUndetectableError{}
28-
}
23+
return actions, nil
2924
}
3025

3126
switch *document.Language {

server/root-handler/shared/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const (
66
LanguageSSHConfig SupportedLanguage = "ssh_config"
77
LanguageSSHDConfig SupportedLanguage = "sshd_config"
88
LanguageFstab SupportedLanguage = "fstab"
9-
LanguageWireguard SupportedLanguage = "languagewireguard"
9+
LanguageWireguard SupportedLanguage = "wireguard"
1010
LanguageHosts SupportedLanguage = "hosts"
1111
LanguageAliases SupportedLanguage = "aliases"
1212
LanguageBitcoinConf SupportedLanguage = "bitcoin_conf"

server/root-handler/shared/singleton.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
package shared
22

33
import (
4+
"config-lsp/common"
5+
46
protocol "github.com/tliron/glsp/protocol_3_16"
57
)
68

79
type OpenedFile struct {
810
Language *SupportedLanguage
11+
12+
// Stores information when the language could not be determined
13+
UnavailableInfo *UnavailableInfo
14+
}
15+
16+
type UnavailableInfo struct {
17+
// Position of `#?lsp.language`
18+
OverwritePosition *common.LocationRange
919
}
1020

1121
var OpenedFiles = make(map[protocol.DocumentUri]OpenedFile)

0 commit comments

Comments
 (0)