neoclide / coc-tsserver

Tsserver extension for coc.nvim that provide rich features like VSCode for javascript & typescript
MIT License
1.05k stars 68 forks source link

Problem with auto indentation for *.tsx files on new lines and <CR> #396

Closed ZacharyRizer closed 1 year ago

ZacharyRizer commented 1 year ago

When inside a .js, .ts, or jsx file indentation is as expected. When I type a set of brackets and press enter it will automatically indent the next line to be be placed in the block. Similaraly if I add a new line (o), it will place the cursor at the correct indentation for that block. For some reason with .tsx files the indentation is always the same as the line it is coming from (meaning it isn't indenting). I have checked what the filetype is (echo &filetype) and it is typescriptreact (which is what the readme states it should be). All other language server aspects work perfectly.

Here are my coc-settings.json

{
  "coc.preferences.extensionUpdateCheck": "daily",
  "coc.preferences.formatOnSaveFiletypes": [
    "cpp",
    "css",
    "cs",
    "go",
    "javascript",
    "javascriptreact",
    "haskell",
    "html",
    "json",
    "lua",
    "markdown",
    "python",
    "scss",
    "typescript",
    "typescriptreact",
    "yml"
  ],
  "diagnostic.floatConfig": { "border": true },
  "emmet.includeLanguages": { "javascript": "javascriptreact", "typescript": "typescriptreact" },
  "go.goplsOptions": {
    "completeUnimported": true
  },
  "hover.floatConfig": { "border": true },
  "html.autoClosingTags": false,
  "languageserver": {
    "haskell": {
      "command": "haskell-language-server-wrapper",
      "args": ["--lsp"],
      "rootPatterns": ["*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml"],
      "filetypes": ["haskell", "lhaskell"]
    }
  },
  "list.insertMappings": {
    "<C-n>": "normal:j",
    "<C-p>": "normal:k"
  },
  "prettier.disableLanguages": ["haskell"],
  "prettier.printWidth": 100,
  "prettier.tabWidth": 2,
  "signature.floatConfig": { "border": true },
  "suggest.floatConfig": { "border": true },
  "sumneko-lua.enableNvimLuaDev": true,
  "Lua.telemetry.enable": true
}
chemzqm commented 1 year ago

The indentation is mostly created by your &indentexpr, not the language server

chemzqm commented 1 year ago

It could work with format on type feature, but only works when type trigger character, and you have to bind <cr> to notify coc.nvim