@@ -17,8 +17,7 @@ import (
17 "github.com/charmbracelet/crush/internal/csync"
17 "github.com/charmbracelet/crush/internal/csync"
18 "github.com/charmbracelet/crush/internal/fsext"
18 "github.com/charmbracelet/crush/internal/fsext"
19 powernapconfig "github.com/charmbracelet/x/powernap/pkg/config"
19 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"
22 "github.com/sourcegraph/jsonrpc2"
21 "github.com/sourcegraph/jsonrpc2"
@@ -215,14 +214,25 @@ func resolveServerName(manager *powernapconfig.Manager, name string) string {
215 return name
214 return name
218−func handlesFiletype(server *powernapconfig.ServerConfig, ext string, language protocol.LanguageKind) bool {
217+func handlesFiletype(sname string, fileTypes []string, filePath string) bool {
219− for _, ft := range server.FileTypes {
218+ if len(fileTypes) == 0 {
220− if protocol.LanguageKind(ft) == language ||
219+ return true
221− ft == strings.TrimPrefix(ext, ".") ||
220+ }
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
229+ if strings.HasSuffix(name, suffix) || filetype == string(kind) {
230+ slog.Debug("Handles file", "name", sname, "file", name, "filetype", filetype, "kind", kind)
223 return true
231 return true
235+ slog.Debug("Doesn't handle file", "name", sname, "file", name)
226 return false
236 return false
@@ -241,9 +251,7 @@ func hasRootMarkers(dir string, markers []string) bool {
243func handles(server *powernapconfig.ServerConfig, filePath, workDir string) bool {
253func 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) &&
247 hasRootMarkers(workDir, server.RootMarkers)
255 hasRootMarkers(workDir, server.RootMarkers)