@@ -17,8 +17,7 @@ import (
1717 "github.com/charmbracelet/crush/internal/csync"
1818 "github.com/charmbracelet/crush/internal/fsext"
1919 powernapconfig "github.com/charmbracelet/x/powernap/pkg/config"
20− "github.com/charmbracelet/x/powernap/pkg/lsp"
21− "github.com/charmbracelet/x/powernap/pkg/lsp/protocol"
20+ powernap "github.com/charmbracelet/x/powernap/pkg/lsp"
2221 "github.com/sourcegraph/jsonrpc2"
2322)
2423
@@ -215,14 +214,25 @@ func resolveServerName(manager *powernapconfig.Manager, name string) string {
215214 return name
216215}
217216
218−func handlesFiletype(server *powernapconfig.ServerConfig, ext string, language protocol.LanguageKind) bool {
219− for _, ft := range server.FileTypes {
220− if protocol.LanguageKind(ft) == language ||
221− ft == strings.TrimPrefix(ext, ".") ||
222− "."+ft == ext {
217+func handlesFiletype(sname string, fileTypes []string, filePath string) bool {
218+ if len(fileTypes) == 0 {
219+ return true
220+ }
221+
222+ kind := powernap.DetectLanguage(filePath)
223+ name := strings.ToLower(filepath.Base(filePath))
224+ for _, filetype := range fileTypes {
225+ suffix := strings.ToLower(filetype)
226+ if !strings.HasPrefix(suffix, ".") {
227+ suffix = "." + suffix
228+ }
229+ if strings.HasSuffix(name, suffix) || filetype == string(kind) {
230+ slog.Debug("Handles file", "name", sname, "file", name, "filetype", filetype, "kind", kind)
223231 return true
224232 }
225233 }
234+
235+ slog.Debug("Doesn't handle file", "name", sname, "file", name)
226236 return false
227237}
228238
@@ -241,9 +251,7 @@ func hasRootMarkers(dir string, markers []string) bool {
241251}
242252
243253func handles(server *powernapconfig.ServerConfig, filePath, workDir string) bool {
244− language := lsp.DetectLanguage(filePath)
245− ext := filepath.Ext(filePath)
246− return handlesFiletype(server, ext, language) &&
254+ return handlesFiletype(server.Command, server.FileTypes, filePath) &&
247255 hasRootMarkers(workDir, server.RootMarkers)
248256}
249257