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

🐛 Biome LSP is treating typescript files as if they were javascript files #3839

Closed
1 task done
lynndylanhurley opened this issue Sep 9, 2024 · 24 comments
Closed
1 task done
Labels
A-LSP Area: language server protocol

Comments

@lynndylanhurley
Copy link

Environment information

CLI:
  Version:                      1.8.3
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v21.4.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         unset

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 false

Workspace:
  Open Documents:               0

What happened?

I'm using neovim. The first TypeScript file that I open is treated correctly as a TypeScript file, but every other TypeScript file after that is analyzed as if it were a JavaScript file, and it throws syntax warnings about the types.

Here are the server logs for one of the incorrect lints:

└─┐biome_lsp::handlers::analysis::code_actions{uri=file:///Users/lynn/Code/Graveflex/nextjs-vercel/apps/web/src/app/(app)/%5blocale%5d/page.tsx, range=Range { start: Position { line: 38, character: 57 }, end: Position { line: 38, character: 57 } }, only=No
ne, diagnostics=[]}
  ├─  0ms DEBUG biome_service::workspace::server File capabilities: Js(JsFileSource { language: JavaScript, variant: Jsx, module
_kind: Module, version: ES2022, embedding_kind: None }) BiomePath { path: "/Users/lynn/Code/Graveflex/nextjs-vercel/apps/web/src
/app/(app)/[locale]/page.tsx" }
  ├─  0ms DEBUG biome_service::workspace The file has the following feature sets: 
  │ {Search: FileNotSupported, OrganizeImports: Supported, Lint: Supported, Format: Supported}
  ├─  0ms DEBUG biome_lsp::handlers::analysis Cursor range 1190..1190
  ├─  0ms DEBUG biome_service::workspace::server File capabilities: Js(JsFileSource { language: JavaScript, variant: Jsx, module
_kind: Module, version: ES2022, embedding_kind: None }) BiomePath { path: "/Users/lynn/Code/Graveflex/nextjs-vercel/apps/web/src
/app/(app)/[locale]/page.tsx" }
  └─┐biome_service::file_handlers::javascript::code_actions{}
    └─┐biome_service::file_handlers::javascript::Code actions JavaScript{range=1190..1190, path=BiomePath { path: "/Users/lynn/C
ode/Graveflex/nextjs-vercel/apps/web/src/app/(app)/[locale]/page.tsx" }}
    ┌─┘
  ┌─┘
  ├─  1ms DEBUG biome_lsp::handlers::analysis Pull actions result: PullActionsResult { actions: [] }
  ├─  1ms DEBUG biome_lsp::handlers::analysis Suggested actions: 
  │ []
┌─┘

You can see in the filename that it's a .tsx file, but for whatever reason it's assuming language: JavaScript instead of language: TypeScript.

Here is the relevant part of my neovim config:

return {
  'VonHeikemen/lsp-zero.nvim',
  branch = 'v4.x',
  lazy = false,
  dependencies = {
    'williamboman/mason.nvim',
    "williamboman/mason-lspconfig.nvim",
    "neovim/nvim-lspconfig",
    "jose-elias-alvarez/nvim-lsp-ts-utils",
    'hrsh7th/cmp-nvim-lsp',
    -- "WhoIsSethDaniel/mason-tool-installer.nvim",
  },
  config = function()
    local lsp_zero = require('lsp-zero')
    local mason_lspconfig = require("mason-lspconfig")

    local lsp_attach = function(client, bufnr)
      local opts = {buffer = bufnr}
    end

    local lsp_servers = {
      'lua_ls',
      'rust_analyzer',
      'ts_ls',
      'biome',
      'eslint',
      'slint_lsp',
      'cssls',
      'dockerls',
      'dotls',
      'graphql',
      'html',
      'yamlls',
      'solargraph',
      'phpactor'
    }

    lsp_zero.extend_lspconfig({
      sign_text = true,
      lsp_attach = lsp_attach,
      capabilities = require('cmp_nvim_lsp').default_capabilities(),
    })

    lsp_zero.setup_servers(lsp_servers)

    require('mason').setup({})
    require('mason-lspconfig').setup({
      ensure_installed = lsp_servers,

      handlers = {
        function(server_name)
          require('lspconfig')[server_name].setup({})
        end,
      }
    })
  end,
  keys = {
    -- format keymaps
    { '<leader>f', vim.lsp.buf.format, desc = 'LspFormat' },

    -- lsp keymaps
    { "gD", vim.lsp.buf.type_definition, desc = 'LspGotoDef' },
    { "gi", vim.lsp.buf.implementation, desc = 'LspGotoImp' }
  }
}

I don't have this same problem with the eslint LSP (or any other LSP).

Expected result

It should always lint TypeScript files using TypeScript rules, not JavaScript rules.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@lynndylanhurley
Copy link
Author

lynndylanhurley commented Sep 9, 2024

The problem was my neovim config. I removed the lsp_attach method and it started working correctly.

The fix was:

    lsp_zero.extend_lspconfig({
      sign_text = true,
      -- lsp_attach = lsp_attach, <-- remove this line
      capabilities = require('cmp_nvim_lsp').default_capabilities(),
    })

UPDATE: ignore this comment, the issue went away temporarily, but it seems to be intermittent.

@lynndylanhurley
Copy link
Author

scratch my last comment. the issue is still happening, it's just intermittent

@dyc3
Copy link
Contributor

dyc3 commented Sep 11, 2024

Can you post your biome config? And does biome still treat it as jsx instead of tsx from the CLI?

@lynndylanhurley
Copy link
Author

hi @dyc3 ! thanks for taking a look. here's our biome config:

{
  "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
  "vcs": {
    "enabled": true,
    "clientKind": "git",
    "useIgnoreFile": true
  },
  "formatter": {
    "enabled": true,
    "formatWithErrors": false,
    "indentStyle": "space",
    "indentWidth": 2,
    "lineEnding": "lf",
    "lineWidth": 80,
    "attributePosition": "auto"
  },
  "organizeImports": { "enabled": true },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": false,
      "a11y": {
        "noAccessKey": "error",
        "noAriaUnsupportedElements": "error",
        "noAutofocus": "error",
        "noBlankTarget": "error",
        "noDistractingElements": "error",
        "noHeaderScope": "error",
        "noInteractiveElementToNoninteractiveRole": "error",
        "noNoninteractiveElementToInteractiveRole": "error",
        "noNoninteractiveTabindex": "error",
        "noPositiveTabindex": "error",
        "noRedundantAlt": "error",
        "noRedundantRoles": "error",
        "useAltText": "error",
        "useAnchorContent": "error",
        "useAriaActivedescendantWithTabindex": "error",
        "useAriaPropsForRole": "error",
        "useButtonType": "error",
        "useHeadingContent": "error",
        "useHtmlLang": "error",
        "useIframeTitle": "error",
        "useKeyWithClickEvents": "error",
        "useKeyWithMouseEvents": "error",
        "useMediaCaption": "error",
        "useValidAnchor": "error",
        "useValidAriaProps": "error",
        "useValidAriaRole": {
          "level": "error",
          "options": { "allowInvalidRoles": [], "ignoreNonDom": false }
        },
        "useValidAriaValues": "error",
        "useValidLang": "error"
      },
      "complexity": {
        "noBannedTypes": "error",
        "noExtraBooleanCast": "error",
        "noMultipleSpacesInRegularExpressionLiterals": "error",
        "noUselessCatch": "error",
        "noUselessConstructor": "error",
        "noUselessFragments": "error",
        "noUselessLabel": "error",
        "noUselessLoneBlockStatements": "error",
        "noUselessRename": "error",
        "noUselessTernary": "error",
        "noUselessThisAlias": "error",
        "noUselessTypeConstraint": "error",
        "noVoid": "error",
        "noWith": "error",
        "useArrowFunction": "off",
        "useLiteralKeys": "error",
        "useRegexLiterals": "error"
      },
      "correctness": {
        "noChildrenProp": "error",
        "noConstAssign": "error",
        "noConstantCondition": "warn",
        "noConstructorReturn": "error",
        "noEmptyCharacterClassInRegex": "error",
        "noEmptyPattern": "error",
        "noGlobalObjectCalls": "error",
        "noInnerDeclarations": "error",
        "noInvalidConstructorSuper": "error",
        "noInvalidUseBeforeDeclaration": "error",
        "noNewSymbol": "error",
        "noNodejsModules": "off",
        "noNonoctalDecimalEscape": "error",
        "noPrecisionLoss": "error",
        "noSelfAssign": "error",
        "noSetterReturn": "error",
        "noSwitchDeclarations": "error",
        "noUndeclaredVariables": "error",
        "noUnreachable": "error",
        "noUnreachableSuper": "error",
        "noUnsafeFinally": "error",
        "noUnsafeOptionalChaining": "error",
        "noUnusedLabels": "error",
        "noUnusedPrivateClassMembers": "off",
        "noUnusedVariables": "error",
        "noVoidElementsWithChildren": "error",
        "useArrayLiterals": "off",
        "useExhaustiveDependencies": "error",
        "useIsNan": "error",
        "useJsxKeyInIterable": "error",
        "useValidForDirection": "error",
        "useYield": "error"
      },
      "security": {
        "noDangerouslySetInnerHtml": "warn",
        "noDangerouslySetInnerHtmlWithChildren": "error",
        "noGlobalEval": "error"
      },
      "style": {
        "noArguments": "error",
        "noCommaOperator": "error",
        "noDefaultExport": "off",
        "noImplicitBoolean": "error",
        "noNamespace": "error",
        "noNegationElse": "off",
        "noParameterAssign": "error",
        "noRestrictedGlobals": {
          "level": "error",
          "options": {
            "deniedGlobals": [
              "isFinite",
              "isNaN",
              "addEventListener",
              "blur",
              "close",
              "closed",
              "confirm",
              "defaultStatus",
              "defaultstatus",
              "event",
              "external",
              "find",
              "focus",
              "frameElement",
              "frames",
              "history",
              "innerHeight",
              "innerWidth",
              "length",
              "location",
              "locationbar",
              "menubar",
              "moveBy",
              "moveTo",
              "name",
              "onblur",
              "onerror",
              "onfocus",
              "onload",
              "onresize",
              "onunload",
              "open",
              "opener",
              "opera",
              "outerHeight",
              "outerWidth",
              "pageXOffset",
              "pageYOffset",
              "parent",
              "print",
              "removeEventListener",
              "resizeBy",
              "resizeTo",
              "screen",
              "screenLeft",
              "screenTop",
              "screenX",
              "screenY",
              "scroll",
              "scrollbars",
              "scrollBy",
              "scrollTo",
              "scrollX",
              "scrollY",
              "self",
              "status",
              "statusbar",
              "stop",
              "toolbar",
              "top"
            ]
          }
        },
        "noUselessElse": "error",
        "noVar": "error",
        "useAsConstAssertion": "error",
        "useBlockStatements": "error",
        "useCollapsedElseIf": "error",
        "useConst": "error",
        "useDefaultParameterLast": "error",
        "useExponentiationOperator": "error",
        "useFragmentSyntax": "error",
        "useImportType": "error",
        "useNumericLiterals": "error",
        "useShorthandAssign": "error",
        "useSingleVarDeclarator": "error",
        "useTemplate": "error"
      },
      "suspicious": {
        "noArrayIndexKey": "error",
        "noAssignInExpressions": "error",
        "noAsyncPromiseExecutor": "error",
        "noCatchAssign": "error",
        "noClassAssign": "error",
        "noCommentText": "error",
        "noCompareNegZero": "error",
        "noConfusingLabels": "error",
        "noConsoleLog": "warn",
        "noControlCharactersInRegex": "error",
        "noDebugger": "error",
        "noDoubleEquals": "error",
        "noDuplicateCase": "error",
        "noDuplicateClassMembers": "error",
        "noDuplicateJsxProps": "error",
        "noDuplicateObjectKeys": "error",
        "noDuplicateParameters": "error",
        "noEmptyBlockStatements": "error",
        "noExplicitAny": "error",
        "noExtraNonNullAssertion": "error",
        "noFallthroughSwitchClause": "error",
        "noFunctionAssign": "error",
        "noGlobalAssign": "error",
        "noImportAssign": "error",
        "noLabelVar": "error",
        "noMisleadingCharacterClass": "error",
        "noMisleadingInstantiator": "error",
        "noPrototypeBuiltins": "error",
        "noRedeclare": "error",
        "noSelfCompare": "error",
        "noShadowRestrictedNames": "error",
        "noUnsafeDeclarationMerging": "error",
        "noUnsafeNegation": "error",
        "useAwait": "off",
        "useDefaultSwitchClauseLast": "error",
        "useGetterReturn": "error",
        "useValidTypeof": "error"
      }
    },
    "ignore": [
      "**/node_modules/**",
      "**/dist/**",
      "**/storybook-static/**",
      "**/.next/**"
    ]
  },
  "javascript": {
    "globals": ["describe", "it"],
    "formatter": {
      "jsxQuoteStyle": "double",
      "quoteProperties": "asNeeded",
      "trailingCommas": "none",
      "semicolons": "always",
      "arrowParentheses": "always",
      "bracketSpacing": true,
      "bracketSameLine": false,
      "quoteStyle": "single",
      "attributePosition": "auto"
    }
  },
  "overrides": [
    { "include": ["*.json"], "formatter": { "indentWidth": 2 } },
    {
      "include": ["*.test.ts*"],
      "javascript": {
        "globals": ["it", "describe"]
      }
    }
  ],
  "files": {
    "ignore": [
      "**/node_modules/**",
      "**/dist/**",
      "**/storybook-static/**",
      "**/.next/**",
      "apps/web/src/migrations/**",
      "**/importMap.js",
      "**/payload-types.ts"
    ]
  }
}

This is what we got from an eslint migration so it might be more complicated than it needs to be.

@lynndylanhurley
Copy link
Author

And no, when i run biome from the CLI, everything is fine. Both biome check and biome check --write work as expected.

@dyc3
Copy link
Contributor

dyc3 commented Sep 11, 2024

It could be your IDE is reporting the file incorrectly. I'm pretty sure this is what the LSP uses to determine the language:

/// Try to return the JS file source corresponding to this language ID
///
/// See the [LSP spec] and [VS Code spec] for a list of language identifiers
///
/// [LSP spec]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentItem
/// [VS Code spec]: https://code.visualstudio.com/docs/languages/identifiers
pub fn try_from_language_id(language_id: &str) -> Result<Self, FileSourceError> {

Edit: Yeah I'm pretty sure this is it. Biome handles the language id correctly.

@lynndylanhurley
Copy link
Author

I'm in neovim, and when I check the filetype with :set filetype? it seems to be coming back with the correct filetype (either filetype=typescript or filetype=typescriptreact). And also this has never happened with the eslint LSP (or any other LSP that I've used).

Is there anything different about how filetypes are derived with the biome LSP compared to the eslint LSP?

@dyc3
Copy link
Contributor

dyc3 commented Sep 11, 2024

I'm not sure tbh. I'm still not super familiar with how the LSP works.

You mentioned that it was intermittent: It could be there's some race condition somewhere. I'm assuming that you checked the filetype while the bug was happening?

@dyc3 dyc3 added the A-LSP Area: language server protocol label Sep 11, 2024
@lynndylanhurley
Copy link
Author

lynndylanhurley commented Sep 11, 2024

It must be something like that, but I don't know how to go about testing for the race condition.

Neovim was reporting the correct filetype while the error was present.

I tried running :LspRestart but it didn't seem to have any effect.

Also if it was a race condition, I would imagine that subsequent requests to the LSP would communicate the correct filetype, but the biome logs continue to show the filetype as language: JavaScript.

@lynndylanhurley
Copy link
Author

@Conaclos i saw that a release just went up with added debugging output. Here is a log capture of this issue happening with the latest version that just went out (1.9.0):

└─┐biome_service::file_handlers::try_from_path{path="/Users/lynn/Code/Dutch/dutchtest/apps/web/src/app/(app)/[locale]/layout.tsx
"}
  └─┐biome_service::file_handlers::try_from_well_known{path="/Users/lynn/Code/Dutch/dutchtest/apps/web/src/app/(app)/[locale]/la
yout.tsx"}
  ┌─┘
  └─┐biome_service::file_handlers::try_from_extension{extension="tsx"}
  ┌─┘
┌─┘
├─ DEBUG biome_service::workspace::server File capabilities: Js(JsFileSource { language: JavaScript, variant: Jsx, module_kind: 
Module, version: ES2022, embedding_kind: None }) BiomePath { path: "/Users/lynn/Code/Dutch/dutchtest/apps/web/src/app/(app)/[loc
ale]/layout.tsx", kind: FileKinds(BitFlags<FileKind>(0b10000, Handleable)), was_written: false }
└─┐biome_service::file_handlers::try_from_path{path="/Users/lynn/Code/Dutch/dutchtest/apps/web/src/app/(app)/[locale]/layout.tsx
"}
  └─┐biome_service::file_handlers::try_from_well_known{path="/Users/lynn/Code/Dutch/dutchtest/apps/web/src/app/(app)/[locale]/la
yout.tsx"}
  ┌─┘
  └─┐biome_service::file_handlers::try_from_extension{extension="tsx"}
  ┌─┘
┌─┘
└─┐biome_service::file_handlers::try_from_path{path="/Users/lynn/Code/Dutch/dutchtest/apps/web/src/app/(app)/[locale]/layout.tsx
"}
  └─┐biome_service::file_handlers::try_from_well_known{path="/Users/lynn/Code/Dutch/dutchtest/apps/web/src/app/(app)/[locale]/la
yout.tsx"}
  ┌─┘
  └─┐biome_service::file_handlers::try_from_extension{extension="tsx"}
  ┌─┘
┌─┘
├─ DEBUG biome_service::workspace The file has the following feature sets: 
│ {OrganizeImports: Supported, Search: Supported, Assists: Supported, Lint: Supported, Format: Supported}
├─ DEBUG biome_lsp::handlers::analysis Cursor range 1244..1244
└─┐biome_service::file_handlers::try_from_path{path="/Users/lynn/Code/Dutch/dutchtest/apps/web/src/app/(app)/[locale]/layout.tsx
"}
  └─┐biome_service::file_handlers::try_from_well_known{path="/Users/lynn/Code/Dutch/dutchtest/apps/web/src/app/(app)/[locale]/la
yout.tsx"}
  ┌─┘
  └─┐biome_service::file_handlers::try_from_extension{extension="tsx"}
  ┌─┘
┌─┘
├─ DEBUG biome_service::workspace::server File capabilities: Js(JsFileSource { language: JavaScript, variant: Jsx, module_kind: 
Module, version: ES2022, embedding_kind: None }) BiomePath { path: "/Users/lynn/Code/Dutch/dutchtest/apps/web/src/app/(app)/[loc
ale]/layout.tsx", kind: FileKinds(BitFlags<FileKind>(0b10000, Handleable)), was_written: false }
└─┐biome_service::file_handlers::try_from_path{path="/Users/lynn/Code/Dutch/dutchtest/apps/web/src/app/(app)/[locale]/layout.tsx
"}
  └─┐biome_service::file_handlers::try_from_well_known{path="/Users/lynn/Code/Dutch/dutchtest/apps/web/src/app/(app)/[locale]/la
yout.tsx"}
  ┌─┘
  └─┐biome_service::file_handlers::try_from_extension{extension="tsx"}
  ┌─┘
┌─┘
└─┐biome_service::file_handlers::try_from_path{path="/Users/lynn/Code/Dutch/dutchtest/apps/web/src/app/(app)/[locale]/layout.tsx
"}
  └─┐biome_service::file_handlers::try_from_well_known{path="/Users/lynn/Code/Dutch/dutchtest/apps/web/src/app/(app)/[locale]/la
yout.tsx"}
  ┌─┘
  └─┐biome_service::file_handlers::try_from_extension{extension="tsx"}
  ┌─┘
┌─┘
└─┐biome_service::file_handlers::javascript::code_actions{}
  └─┐biome_service::file_handlers::javascript::Code actions JavaScript{range=Some(1244..1244), path=BiomePath { path: "/Users/ly
nn/Code/Dutch/dutchtest/apps/web/src/app/(app)/[locale]/layout.tsx", kind: FileKinds(BitFlags<FileKind>(0b10000, Handleable)), w
as_written: false }}
  ┌─┘
┌─┘
├─ DEBUG biome_lsp::handlers::analysis Suggested actions: 
│ []

Also here's a screenshot of my editor while the issue is present:
Screenshot 2024-09-12 at 2 25 48 PM

@dyc3
Copy link
Contributor

dyc3 commented Sep 12, 2024

Ok now we at least know it's not using the language id to determine the language. I forgot to put the returned values in the new logs, but just from this it seems like try_from_extension is determining the file is JavaScript.

I won't be able to take a closer look for a while.

dyc3 added a commit that referenced this issue Sep 13, 2024
@dyc3
Copy link
Contributor

dyc3 commented Sep 13, 2024

I think I know the source for the problem, but not what causes it.

The LSP only calls from_language_id when it receives the textDocument/didOpen LSP notification. When grabbing the file capabilities, the path is used, not the language id.

fn get_file_source(&self, path: &BiomePath) -> DocumentFileSource {
self.documents
.get(path)
.map(|doc| doc.file_source_index)
.and_then(|index| self.get_source(index))
.unwrap_or(DocumentFileSource::from_path(path))
}

Something is happening that is causing these 2 fields on the WorkspaceServer to get out of sync.

/// Stores the document (text content + version number) associated with a URL
documents: DashMap<BiomePath, Document>,

/// Stores the document sources used across the workspace
file_sources: RwLock<IndexSet<DocumentFileSource>>,

I imagine it hasn't come up before if the neovim LSP client sends requests in a different order than the VSCode LSP client.

dyc3 added a commit that referenced this issue Sep 13, 2024
@dyc3
Copy link
Contributor

dyc3 commented Sep 13, 2024

I'll see about getting a new nightly released with the adjusted debug logs. If you could get trace level logs, that would be great.

dyc3 added a commit that referenced this issue Sep 13, 2024
@lynndylanhurley
Copy link
Author

Thank you @dyc3 ! I'll test as soon as the build goes up.

@dyc3
Copy link
Contributor

dyc3 commented Sep 14, 2024

@lynndylanhurley
Copy link
Author

Sorry for the delay @dyc3 . Just updated to v1.9.1, here are the logs during the issue:

└─┐biome_service::file_handlers::try_from_path{path="/Users/lynn/Code/Dutch/dutchtest/packages/theme/src/ThemeProvider.tsx"}
  └─┐biome_service::file_handlers::try_from_well_known{path="/Users/lynn/Code/Dutch/dutchtest/packages/theme/src/ThemeProvider.t
sx"}
  ┌─┘
  └─┐biome_service::file_handlers::try_from_extension{extension="tsx"}
  ┌─┘
┌─┘
├─ DEBUG biome_service::workspace::server File capabilities: Js(JsFileSource { language: JavaScript, variant: Jsx, module_kind: 
Module, version: ES2022, embedding_kind: None }) BiomePath { path: "/Users/lynn/Code/Dutch/dutchtest/packages/theme/src/ThemePro
vider.tsx", kind: FileKinds(BitFlags<FileKind>(0b10000, Handleable)), was_written: false }
└─┐biome_service::file_handlers::try_from_path{path="/Users/lynn/Code/Dutch/dutchtest/packages/theme/src/ThemeProvider.tsx"}
  └─┐biome_service::file_handlers::try_from_well_known{path="/Users/lynn/Code/Dutch/dutchtest/packages/theme/src/ThemeProvider.t
sx"}
  ┌─┘
  └─┐biome_service::file_handlers::try_from_extension{extension="tsx"}
  ┌─┘
┌─┘
└─┐biome_service::file_handlers::try_from_path{path="/Users/lynn/Code/Dutch/dutchtest/packages/theme/src/ThemeProvider.tsx"}
  └─┐biome_service::file_handlers::try_from_well_known{path="/Users/lynn/Code/Dutch/dutchtest/packages/theme/src/ThemeProvider.t
sx"}
  ┌─┘
  └─┐biome_service::file_handlers::try_from_extension{extension="tsx"}
  ┌─┘
┌─┘
├─ DEBUG biome_service::workspace The file has the following feature sets: 
│ {Assists: Supported, Format: Supported, Lint: Supported, OrganizeImports: Supported, Search: Supported}
├─ DEBUG biome_lsp::handlers::analysis Cursor range 0..0
└─┐biome_service::file_handlers::try_from_path{path="/Users/lynn/Code/Dutch/dutchtest/packages/theme/src/ThemeProvider.tsx"}
  └─┐biome_service::file_handlers::try_from_well_known{path="/Users/lynn/Code/Dutch/dutchtest/packages/theme/src/ThemeProvider.t
sx"}
  ┌─┘
  └─┐biome_service::file_handlers::try_from_extension{extension="tsx"}
  ┌─┘
┌─┘
├─ DEBUG biome_service::workspace::server File capabilities: Js(JsFileSource { language: JavaScript, variant: Jsx, module_kind: 
Module, version: ES2022, embedding_kind: None }) BiomePath { path: "/Users/lynn/Code/Dutch/dutchtest/packages/theme/src/ThemePro
vider.tsx", kind: FileKinds(BitFlags<FileKind>(0b10000, Handleable)), was_written: false }
└─┐biome_service::file_handlers::try_from_path{path="/Users/lynn/Code/Dutch/dutchtest/packages/theme/src/ThemeProvider.tsx"}
  └─┐biome_service::file_handlers::try_from_well_known{path="/Users/lynn/Code/Dutch/dutchtest/packages/theme/src/ThemeProvider.t
sx"}
  ┌─┘
  └─┐biome_service::file_handlers::try_from_extension{extension="tsx"}
  ┌─┘
┌─┘
└─┐biome_service::file_handlers::try_from_path{path="/Users/lynn/Code/Dutch/dutchtest/packages/theme/src/ThemeProvider.tsx"}
  └─┐biome_service::file_handlers::try_from_well_known{path="/Users/lynn/Code/Dutch/dutchtest/packages/theme/src/ThemeProvider.t
sx"}
  ┌─┘
  └─┐biome_service::file_handlers::try_from_extension{extension="tsx"}
  ┌─┘
┌─┘
└─┐biome_service::file_handlers::javascript::code_actions{}
  └─┐biome_service::file_handlers::javascript::Code actions JavaScript{range=Some(0..0), path=BiomePath { path: "/Users/lynn/Cod
e/Dutch/dutchtest/packages/theme/src/ThemeProvider.tsx", kind: FileKinds(BitFlags<FileKind>(0b10000, Handleable)), was_written: 
false }}
  ┌─┘
┌─┘
├─ DEBUG biome_lsp::handlers::analysis Suggested actions: 
│ []

@lynndylanhurley
Copy link
Author

@dyc3 hey just making sure you saw my last comment

@dyc3
Copy link
Contributor

dyc3 commented Sep 23, 2024

Thanks, this slipped through the cracks.

@dyc3
Copy link
Contributor

dyc3 commented Sep 23, 2024

Honestly, I'm a bit stumped with this one. I think it would be easier if I could reproduce it on my own machine. I've never used neovim before, is the config you posted above sufficient for me to use? Also, could you narrow down the steps required to reproduce?

@lynndylanhurley
Copy link
Author

lynndylanhurley commented Sep 23, 2024

I can consistently reproduce the problem by opening up a next.js monorepo project and then opening 2 or 3 typescript files. The first one is usually ok, but after the 2nd or 3rd file, each new file is classified as a JavaScript file.

@dyc3 my entire neovim config is up here. i think this file is the only one needed to reproduce, but it gets loaded by this file along with some other basic config.

My config might not be the best starting point for nvim. You might be better off using a pre-built config like LazyVim LunarVim or NvChad. The LSP servers are typically managed by a system called mason.nvim.

I'm also happy to do a screen recording if it would be helpful, just let me know what you want to see.

@dyc3
Copy link
Contributor

dyc3 commented Sep 23, 2024

I'll give it a shot tomorrow. It would be super useful to have a repo already set up. You can use our helper to automate that a little with your preferred package manager:

npm create @biomejs/biome-reproduction

pnpm create @biomejs/biome-reproduction

bun create @biomejs/biome-reproduction

yarn create @biomejs/biome-reproduction

@dyc3
Copy link
Contributor

dyc3 commented Sep 24, 2024

I tried what you said in neovim in a react project, using lazyvim and only adding this to the init.lua:

require'lspconfig'.biome.setup{}

I was not able to reproduce the issue. A screen recording would be good to see exactly what you are doing.

@lynndylanhurley
Copy link
Author

@dyc3 i just switched my config to LazyVim and I haven't been able to reproduce for the past few days.

At this point I'm guessing that my plugins were being initialized in a different order.

I'm going stick with LazyVim as the base for my config, and if the issue comes back I'll re-open this ticket with more info.

Thank you for the effort that you put into debugging this for me.

@gtarsia
Copy link

gtarsia commented Oct 14, 2024

I'm having this issue as well with mason/biome, except my config is lazyvim.
I see that the issue only happens with biome version 1.6.0 up. I set the version like this in neovim: :MasonInstall [email protected].
It is not clear to me if this is an issue with biome, mason or something, but at least I can use biome without this warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LSP Area: language server protocol
Projects
None yet
Development

No branches or pull requests

3 participants