Giter Site home page Giter Site logo

ananthakumaran / tide Goto Github PK

View Code? Open in Web Editor NEW
1.4K 28.0 109.0 26.42 MB

Tide - TypeScript Interactive Development Environment for Emacs

License: GNU General Public License v3.0

Emacs Lisp 97.28% JavaScript 0.22% Makefile 1.39% TypeScript 0.78% Vue 0.33%
typescript emacs

tide's Introduction

Tide

Build Status

TypeScript Interactive Development Environment for Emacs

screencast

Installation

  • Tide requires Emacs 25 or later. We recommend Emacs 27 or later with native json support.
  • Install node.js v0.14.0 or greater.
  • Make sure tsconfig.json or jsconfig.json is present in the root folder of the project.
  • Tide is available in melpa. You can install tide via package-install M-x package-install [ret] tide

Configuration

TypeScript

(defun setup-tide-mode ()
  (interactive)
  (tide-setup)
  (flycheck-mode +1)
  (setq flycheck-check-syntax-automatically '(save mode-enabled))
  (eldoc-mode +1)
  (tide-hl-identifier-mode +1)
  ;; company is an optional dependency. You have to
  ;; install it separately via package-install
  ;; `M-x package-install [ret] company`
  (company-mode +1))

;; aligns annotation to the right hand side
(setq company-tooltip-align-annotations t)

;; formats the buffer before saving
(add-hook 'before-save-hook 'tide-format-before-save)

;; if you use typescript-mode
(add-hook 'typescript-mode-hook #'setup-tide-mode)
;; if you use treesitter based typescript-ts-mode (emacs 29+)
(add-hook 'typescript-ts-mode-hook #'setup-tide-mode)

Format options

Format options can be specified in multiple ways.

  • via elisp
(setq tide-format-options '(:insertSpaceAfterFunctionKeywordForAnonymousFunctions t :placeOpenBraceOnNewLineForFunctions nil))
  • via tsfmt.json (should be present in the root folder along with tsconfig.json)
{
  "indentSize": 4,
  "tabSize": 4,
  "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
  "placeOpenBraceOnNewLineForFunctions": false,
  "placeOpenBraceOnNewLineForControlBlocks": false
}

Check here for the full list of supported format options.

TSX without treesitter

(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
(add-hook 'web-mode-hook
          (lambda ()
            (when (string-equal "tsx" (file-name-extension buffer-file-name))
              (setup-tide-mode))))
;; enable typescript-tslint checker
(flycheck-add-mode 'typescript-tslint 'web-mode)

TSX with treesitter

Treesitter comes with tsx major mode built in.

(add-hook 'tsx-ts-mode-hook #'setup-tide-mode)

Tide also provides support for editing js & jsx files. Tide checkers javascript-tide and jsx-tide are not enabled by default for js & jsx files. It can be enabled by setting flycheck-checker

JavaScript

Create jsconfig.json in the root folder of your project. jsconfig.json is tsconfig.json with allowJs attribute set to true.

{
  "compilerOptions": {
    "target": "es2017",
    "allowSyntheticDefaultImports": true,
    "noEmit": true,
    "checkJs": true,
    "jsx": "react",
    "lib": [ "dom", "es2017" ]
  }
}
(add-hook 'js2-mode-hook #'setup-tide-mode)
;; configure javascript-tide checker to run after your default javascript checker
(flycheck-add-next-checker 'javascript-eslint 'javascript-tide 'append)

JSX

(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.jsx\\'" . web-mode))
(add-hook 'web-mode-hook
          (lambda ()
            (when (string-equal "jsx" (file-name-extension buffer-file-name))
              (setup-tide-mode))))
;; configure jsx-tide checker to run after your default jsx checker
(flycheck-add-mode 'javascript-eslint 'web-mode)
(flycheck-add-next-checker 'javascript-eslint 'jsx-tide 'append)

Use Package

;; if you use typescript-mode
(use-package tide
  :ensure t
  :after (typescript-mode company flycheck)
  :hook ((typescript-mode . tide-setup)
         (typescript-mode . tide-hl-identifier-mode)
         (before-save . tide-format-before-save)))
         
;; if you use treesitter based typescript-ts-mode (emacs 29+)
(use-package tide
  :ensure t
  :after (company flycheck)
  :hook ((typescript-ts-mode . tide-setup)
         (tsx-ts-mode . tide-setup)
         (typescript-ts-mode . tide-hl-identifier-mode)
         (before-save . tide-format-before-save)))

Commands

Keyboard shortcuts Description
M-. Jump to the definition of the symbol at point. With a prefix arg, Jump to the type definition.
M-, Return to your pre-jump position.

M-x tide-restart-server Restart tsserver. This would come in handy after you edit tsconfig.json or checkout a different branch.

M-x tide-documentation-at-point Load the documentation for the symbol at point to buffer *tide-documentation*.

M-x tide-references List all references to the symbol at point in a buffer. References can be navigated using n and p. Press enter to open the file.

M-x tide-project-errors List all errors in the project. Errors can be navigated using n and p. Press enter to open the file.

M-x tide-error-at-point Load the details of the error at point to buffer *tide-error*.

M-x tide-rename-symbol Rename all occurrences of the symbol at point.

M-x tide-rename-file Rename current file and all it's references in other files.

M-x tide-format Format the current region or buffer.

M-x tide-fix Apply code fix for the error at point. When invoked with a prefix arg, apply code fix for all the errors in the file that are similar to the error at point.

M-x tide-add-tslint-disable-next-line If the point is on one or more tslint errors, add a tslint:disable-next-line flag on the previous line to silence the errors. Or, if a flag already exists on the previous line, modify the flag to silence the errors.

M-x tide-refactor Refactor code at point or current region.

M-x tide-jsdoc-template Insert JSDoc comment template at point.

M-x tide-verify-setup Show the version of tsserver.

M-x tide-organize-imports Organize imports in the file.

M-x tide-list-servers List the tsserver processes launched by tide.

Features

  • Xref
  • ElDoc
  • Auto complete
  • Flycheck
  • Jump to definition, Jump to type definition
  • Find occurrences
  • Rename symbol
  • Imenu
  • Compile On Save
  • Highlight Identifiers
  • Code Fixes
  • Code Refactor
  • Organize Imports

Debugging

architecture

Tide uses tsserver as the backend for most of the features. It writes out a comprehensive log file which can be captured by setting tide-tsserver-process-environment variable.

(setq tide-tsserver-process-environment '("TSS_LOG=-level verbose -file /tmp/tss.log"))

FAQ?

How do I configure tide to use a specific version of TypeScript compiler?

For TypeScript 2.0 and above, you can customize the tide-tsserver-executable variable. For example

(setq tide-tsserver-executable "node_modules/typescript/bin/tsserver")

Sadly, this won't work for TypeScript < 2.0. You can clone the repo locally and checkout the old version though.

How do I copy the type information shown in the minibuffer?

Tide has the command tide-documentation-at-point to load the documentation for the symbol at point to buffer *tide-documentation* from where it can be copied. By default, tide will not open this buffer if only type information is available. This behavior can be overridden by setting (setq tide-always-show-documentation t)

Custom Variables

tide-sync-request-timeout 2

The number of seconds to wait for a sync response.

tide-tsserver-flags nil

List of additional flags to provide when starting tsserver.

tide-tsserver-process-environment 'nil

List of extra environment variables to use when starting tsserver.

tide-tsserver-executable nil

Name of tsserver executable to run instead of the bundled tsserver.

This may either be an absolute path or a relative path. Relative paths are resolved against the project root directory.

Note that this option only works with TypeScript version 2.0 and above.

tide-tscompiler-executable nil

Name of tsc executable.

This may either be an absolute path or a relative path. Relative paths are resolved against the project root directory.

tide-node-executable "node"

Name or path of the node executable binary file.

tide-node-flags nil

List of flags to provide to node when starting tsserver.

Useful for large TypeScript codebases which need to set max-old-space-size to a higher value.

tide-post-code-edit-hook nil

Hook run after code edits are applied in a buffer.

tide-sort-completions-by-kind nil

Whether completions should be sorted by kind.

tide-format-options 'nil

Format options plist.

tide-user-preferences '(:includeCompletionsForModuleExports t :includeCompletionsWithInsertText t :allowTextChangesInNewFiles t :generateReturnInDocTemplate t)

User preference plist used on the configure request.

Check https://github.com/Microsoft/TypeScript/blob/17eaf50b/src/server/protocol.ts#L2684 for the full list of available options.

tide-disable-suggestions nil

Disable suggestions.

If set to non-nil, suggestions will not be shown in flycheck errors and tide-project-errors buffer.

tide-completion-setup-company-backend t

Add company-tide to company-backends.

tide-completion-ignore-case nil

CASE will be ignored in completion if set to non-nil.

tide-completion-show-source nil

Completion dropdown will contain completion source if set to non-nil.

tide-completion-fuzzy nil

Allow fuzzy completion.

By default only candidates with exact prefix match are shown. If set to non-nil, candidates with match anywhere inside the name are shown.

tide-completion-detailed nil

Completion dropdown will contain detailed method information if set to non-nil.

tide-completion-enable-autoimport-suggestions t

Whether to include external module exports in completions.

tide-enable-xref t

Whether to enable xref integration.

tide-navto-item-filter #'tide-navto-item-filter-default

The filter for items returned by tide-nav. Defaults to class, interface, type, enum

tide-jump-to-definition-reuse-window t

Reuse existing window when jumping to definition.

tide-imenu-flatten nil

Imenu index will be flattened if set to non-nil.

tide-allow-popup-select '(code-fix refactor)

The list of commands where popup selection is allowed.

tide-always-show-documentation nil

Show the documentation window even if only type information is available.

tide-server-max-response-length 102400

Maximum allowed response length from tsserver. Any response greater than this would be ignored.

tide-tsserver-locator-function #'tide-tsserver-locater-npmlocal-projectile-npmglobal

Function used by tide to locate tsserver.

tide-project-cleanup-delay 60

The number of idle seconds to wait before cleaning up unused tsservers. Use nil to disable automatic cleanups. See also tide-do-cleanups.

tide-tsserver-start-method 'immediate

The method by which tide starts tsserver. immediate causes tide to start a tsserver instance as soon as tide-mode is turned on. manual means that tide will start a tsserver only when the user manually starts one.

tide-default-mode "TS"

The default mode to open buffers not backed by files (e.g. Org source blocks) in.

tide-recenter-after-jump t

Recenter buffer after jumping to definition

tide-jump-to-fallback #'tide-jump-to-fallback-not-given

The fallback jump function to use when implementations aren't available.

tide-filter-out-warning-completions nil

Completions whose :kind property is "warning" will be filtered out if set to non-nil. This option is useful for Javascript code completion, because tsserver often returns a lot of irrelevant completions whose :kind property is "warning" for Javascript code. You can fix this behavior by setting this variable to non-nil value for Javascript buffers using setq-local macro.

tide-native-json-parsing `(and

(>= emacs-major-version 27) (functionp 'json-serialize) (functionp 'json-parse-buffer) (functionp 'json-parse-string))`

Use native JSON parsing (only emacs >= 27).

tide-save-buffer-after-code-edit t

Save the buffer after applying code edits.

tide-hl-identifier-idle-time 0.5

How long to wait after user input before highlighting the current identifier.

tide's People

Contributors

aaronjensen avatar ananthakumaran avatar bolasblack avatar d4ncer avatar deniskyashif avatar duxovni avatar elibarzilay avatar felipeochoa avatar hateonion avatar invokesus avatar jakejx avatar jbms avatar josteink avatar kevinvillela avatar kijowski avatar lddubeau avatar phst avatar phuhl avatar ramblehead avatar robbert-vdh avatar rymndhng avatar sandersn avatar simplify avatar sk1e avatar sleepful avatar sw9 avatar syohex avatar syrupthinker avatar thanhvg avatar vshender avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tide's Issues

Completion casing

Hi!
use company for completiong, given the completion "SomeThing", typing 'somet' will not trigger the completion 'SomeThing'.

What I want is for the following: given the completion "SomeThing", typing "somet" will trigger the completion "SomeThing". That is, the filtering ignores case, but the completion keeps case.

Is there a way of enabling this that I've missed?

Thanks!

Tide not picking up globals as of a couple weeks ago

This is probably more of a support issue than a bug, but I couldn't find another way to get help(sorry).

Recently ( I think within the past couple weeks) tide has stopped picking up my global type definitions. It just says "Cannot find name "

When I compile the same files with typescript + webpack it works fine.

I am using the melpa version of tide, typescript 1.8.10, and typings 1.3.2.

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "sourceMap": true,
    "module": "commonjs"
  },
  "exclude": [
    "node_modules",
    "typings/index.d.ts",
    "typings/"
  ]
}

typings.json

{
  "globalDependencies": {
    "angular": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular.d.ts#fa3294c560ee49f4af43e02a62e3f4b5b6bbe5e5",
    "angular-ui-bootstrap": "registry:dt/angular-ui-bootstrap#0.13.3+20160602140119",
    "angular-ui-router": "registry:dt/angular-ui-router#1.1.5+20160521151413",
    "jquery": "github:DefinitelyTyped/DefinitelyTyped/jquery/jquery.d.ts#4cdfbe96b666eec5e1defbb519a62abf04e96764",
    "lodash": "github:typed-typings/npm-lodash/global#73a6037f16173baee0b40136eee07b2c7ad243c8",
    "moment": "github:DefinitelyTyped/DefinitelyTyped/moment/moment.d.ts#56295f5058cac7ae458540423c50ac2dcf9fc711",
    "moment-node": "github:DefinitelyTyped/DefinitelyTyped/moment/moment-node.d.ts#122b5dd8d183028e514d7cc531340847b22d6c26"
  },
  "globalDevDependencies": {
    "jasmine": "registry:dt/jasmine#2.2.0+20160505161446"
  }
}

typescript.el

(use-package tide
  :ensure t
  :init
  (add-hook 'typescript-mode-hook
          (lambda ()
            (tide-setup)
            (flycheck-mode +1)
            (setq flycheck-check-syntax-automatically '(save mode-enabled))
            (eldoc-mode +1)
            ;; company is an optional dependency. You have to
            ;; install it separately via package-install
            (company-mode +1))))

No Project

What does this error message mean?

Error from syntax checker typescript-tide: Error processing request. No Project.

It seems that this might have been caused by the following in tsconfig.json:

"files": [
  "node_modules/reflect-metadata/reflect-metadata.d.ts"
],

option for setting tsserver path

At present the tsserver is the one which comes with the project, can there be a mechanism provided to explicitly set the tsserver path? The reason this would be helpful is I work on a project which uses the latest tsserver (typescript@next version) and some of the features are not detected by the stock tsserver provided along with the package. I am aware that I can set the tide-tsserver-directory directly and restart to make it work, but would be better if there was a way to do that without changing package specific variables.

P.S. If you are short of time I can help by creating a PR*

(* - I am not very good at writing elisp programs)

Tide should support a TypeScript repl (via comint)

When developing, it's always nice to be able to evaluate code as you move along.

The simplest way to achieve this would probably just to integrate with an existing Type-script repl via Emacs comint. An example of such a comint (for Javascript) is js-comint.

tsun is such a repl for TypeScript.

Would it be possible to make a comint like this ported for tide, or would it make more sense to develop as its own package?

Use filesGlob if available

Hey Tide maintainer :D,

More and more tools are using the filesGlob property, if available, instead of files. It has gotten to the point where our repos wipe the files property from tsconfig.json when committing. Is it possible to modify the server to use filesGlob if it is available?

Cheers,
SerialVelocity

Support for angular templates

I see some editors are now starting to support smart editing of angular templates, including type-checking of referenced properties on the underlying component. I understand this is based on some fork of typescript which provides additional necessary metadata. This is something that would be lovely to have.

Indentation of isolated brace after function declaration

Howdy. Trying to get started w/both TypeScript and tide.

I'm one of those braces-on-lines-by-themselves people, and when I define a function and put the brace on the next line, it gets indented, and then the next line gets indented even more:

   identity<T>( anArray: Array<T>): Array<T> 
      {
         console.log( `Length of array is: ${anArray.length}`);
         return anArray;
      }

I don't see anything obvious in the customize settings, and I tried running c-set-style and got the message "Not a CC Mode buffer" or some such.

I could dust off my elisp debugging skills and drill into this, but I don't really have time, so... is there something simple I've missed?

My only config is this:

(add-hook 'typescript-mode-hook
          (lambda ()
            (tide-setup)
            (flycheck-mode +1)
            (eldoc-mode +1)
            (company-mode-on)
            (setq typescript-indent-level 3)
            ))

GNU Emacs 24.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2013-03-13 on bob.porkrind.org

Thanks.

tide not seeing my node binary

(getenv "PATH")
;; "/Users/jeffrabovsky/.nvm/versions/node/v5.5.0/bin/:/usr/bin/:/bin/:/usr/sbin/:/sbin/:/opt/homebrew-cask/Caskroom/emacs/24.5-1/Emacs.app/Contents/MacOS/bin-x86_64-10_9/:/opt/homebrew-cask/Caskroom/emacs/24.5-1/Emacs.app/Contents/MacOS/libexec-x86_64-10_9/"

(shell-command "node -v")
;; "v.5.5.0"

But when I run M-x tide-restart-server in a buffer within my Typescript project I get: Searching for program: no such file or directory, node

Any ideas what's going on here? Thanks

tide-format-options

If I follow through the code correctly, the README.md is outdated, since it mentions

(setq tide-format-options '(:insertSpaceAfterFunctionKeywordForAnonymousFunctions t :placeOpenBraceOnNewLineForFunctions nil))

but these options are not being passed to the tsserver AFAICS.

The point is not the possibly outdated README.md but how to actually pass options to the tsserver i.e. I format on save, but I don't want spaces in between the braces, but those settings :spaceAfterOpenBrance nil :spaceBeforeCloseBrance don't propagate. Any help is appreciated

Getting warnings about decorators, says to pass --experimentalDecorators

I'm trying to switch from emacs-tss to tide but when I load any TS file that has a decorator in it I get warnings that say that decorators are experimental and I should pass --experimentalDecorators to get rid of the warnings.

I originally added experimentalDecorators: true to my tsconfig.json files compilerOptions but the warnings didn't go away. After a little more investigation it seems experimentalDecorators is not one of the compilerOptions (https://github.com/Microsoft/TypeScript/wiki/Compiler-Options).

Am I missing something?

Tide stops working after file renames

I am receiving the same error as @notnarb when saving an existing .ts file under a new name using C-x C-w. No new buffer is opened, but opening it manually using helm-projectile works fine.

Failed to verify signature

Hey guys,

I got this problem, and I don't even know if it is related to the package.
But I've just upgraded my other packages, and the only one that threw me the error was this one.

The error:
Failed to verify signature seq-2.16.tar.sig: ("Bad signature from 474F05837FBDEF9B GNU ELPA Signing Agent <[email protected]>")

Anyone can head me to the solution?

Thanks!

Error with newest melpa version

When I try to install the newest version of tide from melpa, I get the following error. I had to disable tide because of this error.

Debugger entered--Lisp error: (invalid-read-syntax ")")
  read(#<buffer  *load*>)
  eval-buffer(#<buffer  *load*> nil "/Users/achernyak/.emacs.d/elpa/tide-20161102.848/tide.el" nil t)  ; Reading at buffer position 20066
  load-with-code-conversion("/Users/achernyak/.emacs.d/elpa/tide-20161102.848/tide.el" "/Users/achernyak/.emacs.d/elpa/tide-20161102.848/tide.el" t t)
  require(tide nil t)
  (not (require (quote tide) nil (quote t)))
  (if (not (require (quote tide) nil (quote t))) (ignore (message (format "Cannot load %s" (quote tide)))) (condition-case err (progn (setq company-tooltip-align-annotations t) (setq typescript-indent-level 2) (add-hook (quote typescript-mode-hook) (function setup-tide-mode)) (add-hook (quote web-mode-hook) (function (lambda nil (if (string-equal "tsx" ...) (progn ...)))))) ((debug error) (ignore (display-warning (quote use-package) (format "%s %s: %s" "tide" ":config" (error-message-string err)) :error)))) (if (fboundp (quote diminish)) (diminish (quote tide-mode))) t)
  (progn (progn (require (quote package)) (use-package-ensure-elpa (quote tide))) (if (not (require (quote tide) nil (quote t))) (ignore (message (format "Cannot load %s" (quote tide)))) (condition-case err (progn (setq company-tooltip-align-annotations t) (setq typescript-indent-level 2) (add-hook (quote typescript-mode-hook) (function setup-tide-mode)) (add-hook (quote web-mode-hook) (function (lambda nil (if ... ...))))) ((debug error) (ignore (display-warning (quote use-package) (format "%s %s: %s" "tide" ":config" (error-message-string err)) :error)))) (if (fboundp (quote diminish)) (diminish (quote tide-mode))) t))
  eval((progn (progn (require (quote package)) (use-package-ensure-elpa (quote tide))) (if (not (require (quote tide) nil (quote t))) (ignore (message (format "Cannot load %s" (quote tide)))) (condition-case err (progn (setq company-tooltip-align-annotations t) (setq typescript-indent-level 2) (add-hook (quote typescript-mode-hook) (function setup-tide-mode)) (add-hook (quote web-mode-hook) (function (lambda nil (if ... ...))))) ((debug error) (ignore (display-warning (quote use-package) (format "%s %s: %s" "tide" ":config" (error-message-string err)) :error)))) (if (fboundp (quote diminish)) (diminish (quote tide-mode))) t)) nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

How do I debug "No project"?

I have a directory containing a tsconfig.json. If I create a foo.ts file in that directory and hit M-. on an identifier in it, I get: Error processing request. No Project.

Tide works for me on other projects so it's clearly something particular about this one, but how can I debug it?

Make `tide-references` behave like occur and compilation-mode

When you use occur or compile things using compilation-mode, you get the results presented in a buffer which where you can navigate between the results using previous-error and next-error (even though not all things are errors).

I have these commands conveniently bound to F7 and F8 and it works pretty much for all things Emacs. All things except tide's tide-references.

Would this be possible to add?

Custom Indent Break?

The latest tide release break my custom indent.
I used to set indent to 2 space but now it doesn't work.
The 20160527 version works, so I review the code and found the line

`(:tabSize ,tab-width :indentSize ,typescript-indent-level)

modified to

`(:tabSize ,tab-width)

Why delete the indentSize ? I found it still useful in tsserver.

tsserver exists [sic]: abort trap: 6.

I just upgraded to TS2 and I'm having a problem where tsserver only stays open for about 5 seconds before dying either from "killed: 9" or "abort trap: 6", even on the test project included in this repo.

I've attached a tss.log generated from this crash. I looked at it - it doesn't show any obvious signs of failure. Requests seem to get completed while the server is up - I can get it to reformat my file if I'm fast enough.

When starting tsserver from the command line it seems to work fine. I can replay some of the commands from the log into the terminal window and I get good results, and the server never dies.

I'm on OS X 10.11.5, emacs 24.1.1, using spacemacs, latest version off elpa.

Let me know if there are any other logs I can gather.

tss.txt

flycheck doesn't use next syntax checker (tslint) after tide

Bug Observed: Flycheck does not apply the tslint syntax checker after applying the tide syntax checker. I report this behavior as an issue because line 1091 in tide.el suggests an intent to execute these syntax checkers consecutively.

Context: I installed typescript-mode and tide, as well as typescript and tslint, for the first time tonight. I followed the configuration recommended in the readme.md for those files. My dot files are publically available on my github account.

Documentation of Observation: In the first attached screenshot, I have a main.ts file (top left window) that violates multiple tslint rules (tslint.json in bottom right window). The tide syntax checker is active, and the tslint syntax checker is not disabled (top right frame). And, my dot files contain the code from the tide readme.md (bottom left window). However, the only error/warnings that flycheck displays in the buffer are those from tide.

screen shot 2016-10-09 at 1 33 36 am

Steps Taken: When I manually select typescript-tslint as the syntax checker for a buffer, flycheck applies tslint as expected, but flycheck does not use the tide syntax checker next.

However, I tried fixing all errors raised by the tide syntax checker, and the tslint syntax checker does run. (See second screenshot).

screen shot 2016-10-09 at 2 00 57 am

Hypothesis and Possible Solution: I think errors from the tide syntax checker block flycheck from running the next syntax checker (tslint). Perhaps reversing the order of the syntax checkers would allow errors/warnings from both checkers to display in the buffer.

Thank you for developing and maintaining tide. If I can be of any further assistance, I am happy to help.

No completion at beginning of buffer

I'm getting no completion candidates on a prefix which is at the very beginning of a buffer, for example:

con|

(with point indicated by |).

When I do M-x company-diag, instead of its normal output, I get an error in the echo area: Wrong type argument: characterp, nil.

After a little debugging, I think I've found the problem and I may have a fix. I will create a pull request soon.

Bad JSON error

Using node 0.12.x sadly doesn't fix the "Bad JSON" error for me. It seems that they have fixed it for Sublime (microsoft/TypeScript-Sublime-Plugin#388), so I tried to use the tsserver from this version (microsoft/TypeScript#5408). I patched it with your geterr.patch and compiled it but it didn't work. I think they changed the schema a little bit, it complains about an undefined field.
I don't know whether this is a good idea anyway with it being a different TypeScript version. I was wondering whether you had any new ideas or hints that I could try.

Original TypeScript issue: microsoft/TypeScript#2758

Allow use of newer version of TypeScript?

Would it be feasible to add support for using a newer version of TypeScript? I'm currently trying typescript@next to get 1.6.0-dev features but this means tide complains about new constructs.

Tide is only seems to be active for a single buffer

Hi @ananthakumaran,

First and foremost, thank you for the awesome project! I've stumbled on an issue with more-or-less the default configuration you've provided. The issue I have is that Tide seems to be active only for one buffer, the 1st *.ts file I open. From there on consecutive *.ts files do trigger the typescript-mode-hook, however besides the syntax highlighting nothing seems to be working. No eldoc, no flycheck, no company-mode either. Once I kill the 1st *.ts buffer I've opened (where Tide works fine), the next *.ts file opened will working correctly.

I've used:

  • tide-20160130.43
  • GNU Emacs 24.5.2
  • node v4.2.6

My typescript specific emacs configuration

The project I've tried it with

If you need anything else, just let me know!

Thanks!

Regards,
@snorbi07

Beter syntax highlight using js2-mode

I configured tide-mode with js2-mode instead of typescript-mode, the result is much better,
why not use js2-mode that has better syntax highlight?

Thanks for tide-mode :)

js2-typescript

error when opening in .tsx files

getting the following error when I open a .tsx file in my editor Error from syntax checker typescript-tide: Error processing request. Could not find file: 'file/at/path.tsx'. The plugin works flawlessly when I use it on .ts files. Any pointers on what I might be doing wrong would be great

Conflicting indent style in switch statements

I think typescript-mode is having a fight with the tide formatter about how switch statements should look? When I am editing a file, typescript-mode will indent switch statements like this:

switch ($foo) {
case 123:
    break;
}

But when I save the file with formatting enabled, it changes it to this:

switch ($foo) {
    case 123:
        break;
}

And they will just keep going back and forth as I edit. Is there a config option somewhere I'm missing to change this? I'd prefer the second style for both.

Using these from the readme:
'(:insertSpaceAfterFunctionKeywordForAnonymousFunctions t :placeOpenBraceOnNewLineForFunctions nil)
typescript-mode ver: 0.1 / 20160616.2007

Make tide-tsserver-executable use relative paths

If your TS projects always have typescript as an npm devDependency, then it will be nice to do:

(setq tide-tsserver-executable "node_modules/typescript/bin/tsserver")

and make tide always use the local tsserver from each project.

tide does not pick up .d.ts file in tsconfig.json

It seems like when I specify a .d.ts file in tsconfig.json (with "files" setting), tide doesn't pick it up and will complain (Cannot find name ...), even though tsc will work fine with such setting.

Right now, I have to manually add /// <reference path="" /> in every individual files to make it work, but it's very inconvenient, and it seems to me it will be an issue with larger project with multiple .d.ts files in the source. Is it a bug or expected behaviour by tide?

Taking a look over to other editors, I think all of them are supposedly picking up definitions in .d.ts given that is specified in "files" of tsconfig.json

Where is company-mode?

The README says to install company-mode, but I can't find it in any repository. What am I missing?

BTW, thanks for this fabulous package. It is going to make a major difference in my productivity.

typing `document.b' in an empty document kills the server

Hello,
sorry, I am very new to ts and thus also to tide, so I am sorry if I am missing something obvious. However, I discovered that the following minimum non-working example crashes tide and requires a restart of the server:
tsconfig.json:

{
    "compilerOptions": {
        "target": "ES5",
        "module": "commonjs",
        "sourceMap": true,
    "rootDir": ".",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true
    },
    "exclude": [
        "node_modules"
    ]
}

Creating a new .ts file in the same folder works initially. Ie. autocompletion and type base method completion works as expected. However, just typing document.b (I was going for document.body) kills the server and fills the *Message* buffer with the following:

error in process filter: json-read-object: Bad JSON object: ":", 115
error in process filter: Bad JSON object: ":", 115
error in process filter: json-read-object: Bad JSON object: ":", 115
error in process filter: Bad JSON object: ":", 115

I was able to reproduce this behavior with node v4.2.2 and v5.1.0 and tide from elpa 20151015.1820

Any ideas on the reason for this behavior and how to solve the problem?

speed issues on windows

Hi,

I know - windows- sigh, sorry. We all kneel before that mountain sometimes.

Now, my issue is that codecompletion on an angular2 and three js boilerplate project is a good 6 seconds before company comes back. Backend time-outs are rife. Flycheck is annoying because it lags my cursor movements.
Now this is on a surface pro, the first one and it is no speedmonster, but the difference in speed with vscode is intense. vscode just flies.

So, some tips on how to improve speed would be greatly appreciated.

Alternatively, I would like to propose that linting and codecompletion is done by command, a shortcut key. This way I am in control of the wait and I am pushed to just get it right.
Usually I use codecompletion as a way to quickbrowse a library, maybe there is another way to quickly browse a lib ?

tips appreciated,
Sander

Make `tide-references` jump directly to a single usage

If there is a single usage of a symbol, then tide-references should jump directly to it instead of creating a tide-references buffer. Then tide-jump-to-definition jumps back to the definition. For example:

/*1*/function usedOnce() { }
/*2*/usedOnce();

When the cursor is at (1), tide-references should jump to (2). When the cursor is at (2), tide-jump-to-definition should jump to (1). Otherwise (in case there is more than one usage or more than one declaration), tide-references should be created normally.

Note that this requires TypeScript 2.0, which adds isDefinition to ReferenceEntry to support this feature. e1128b7 adds this feature if you want to take a look -- I'll create a PR for it soon.

Fix compile warnings: undefined variables

Very minor issue, but right now there are references to free variables from other packages:

In tide-current-indentsize:
third_party/elisp/tide/tide.el:366:16:Warning: reference to free variable
    `js2-basic-offset'
third_party/elisp/tide/tide.el:367:15:Warning: reference to free variable
    `js-indent-level'
third_party/elisp/tide/tide.el:368:16:Warning: reference to free variable
    `js3-indent-level'
third_party/elisp/tide/tide.el:369:16:Warning: reference to free variable
    `web-mode-code-indent-offset'
third_party/elisp/tide/tide.el:370:20:Warning: reference to free variable
    `sgml-basic-offset'

In end of data:
third_party/elisp/tide/tide.el:1078:1:Warning: the following functions are not
    known to be defined: company-grab-symbol-cons, company-begin-backend,
    company-in-string-or-comment

It appears the recommended solution is to just add blank declarations for the variables (not sure about the functions, since they are a result of the optional dependency on company-mode, which is not a required package).

Tide not working on large project

I'm working on a large TypeScript project and I don't have a custom tsconfig.json file, so I added an empty file at the root of the project.

The tsserver runs but the problem is tide doesn't seem to work. When I run a tide command, it freezes for a second or so and I get:
eldoc error: (error Sync request timed out quickinfo)
or
eldoc error: (error Sync request timed out signatureHelp)

How could I resolve this?

Error on tide-setup

Throws

 File mode specification error: (error "typescript-tslint is not a valid Flycheck syntax checker") 

while opening file
I have the following hook

(add-hook 'typescript-mode-hook
          '(lambda ()
             (tide-setup)
             (eldoc-mode +1)
             ))

and have global-flycheck-mode enabled

tide + tramp

hi all,

Congrantz for this great module it works fantastic.

Only I have an issue. My angular project is not in local, I access it via TRAMP (SSH), the code is decoracted, but I can't use any of the tide-commands, It always return:

eldoc error: (Server does not exist. Run M-x tide-restart-server to start it again)

If I run the proposed command. It dumps this:

(client) tsserver exists: exited abnormally with code 1.

Because tsserver must be running in local machine, but not in remote.

In remote machine I've got emacs + tide configured and 100% working.

Exists any way to fix this situation?

Thanks.

Best Regards.
Antonio

Update exec path

I'm just installing tide on my Mac. I've installed node, which goes into /usr/local/bin directory. The global PATH is updated thanks to my bashrc.

When I launch the emacs app from the Dock neither the PATH nor the exec-path var contains the correct path, that is /usr/local/bin. If we do not update the snippet of code for the quick install, it would be great to mention it in the README.md file. As you wish. :-)

(setq exec-path (append exec-path '("/usr/local/bin")))

Make the completion functionality independent of company-mode

Not everyone uses company-mode for code completion. Another popular approach, I believe, is using C-M-i combination for getting a list of possible completions in another buffer. This approach works for me pretty good in combination with helm. Could you consider changing the plugin behavior the way to support different completion front-ends?

Support separate face for interpolated part of template string

I'm going to look at hacking this in myself, but I have no experience writing emacs modes so it'll be difficult for me to figure out.

I would like a typescript template string:

`I am a template string ${blargh} see me interpolate!`

To have a separate face on the ${blargh} part compared to the rest of the template string.

This makes it easier for the human to parse the template strings in my opinion.

See https://www.typescriptlang.org/docs/handbook/basic-types.html if you are unfamiliar with template strings (I think they were implemented fairly recently?)

Support for tsonfig.json:compileOnSave

This top-level property in tsconfig.json is used to signal the editor to compile on save. This should be pretty simple for emacs to pick up ๐Ÿ˜„

vermiculus/sx.el uses some solid json-parsing tools, though I don't know what they are off-hand.

Latest released tide (tide-20160706.731) fails with "Error processing request. No Project."

Environment: Ubuntu 16.04, Emacs 24.5.1, tide-20160706.731

Steps to reproduce:

$ mkdir tide-test && cd tide-test
$ echo {} > package.json
$ echo {} > tsconfig.json # alternatively: echo '{"files":["main.ts"]}'
$ npm install --save [email protected]
$ echo "const a: number = 100; console.log(a)" > main.ts
$ node_modules/.bin/tsc
$ node main.js
100
$ emacs main.ts

An error pops up. Log (log level debug) included below

Info 0    request: {"command":"syntacticDiagnosticsSync","seq":"1","arguments":{"file":"\/home\/bhorsley\/Workspace\/tide-test\/main.ts"}}
Err 1     Exception on executing command {"command":"syntacticDiagnosticsSync","seq":"1","arguments":{"file":"\/home\/bhorsley\/Workspace\/tide-test\/main.ts"}}:
No Project.
Error: No Project.
    at Errors (/home/bhorsley/dotfiles/.emacs.d/.cask/24.5.1/elpa/tide-20160706.731/tsserver/tsserver.js:59651:32)
    at ts.server.ts.server (/home/bhorsley/dotfiles/.emacs.d/.cask/24.5.1/elpa/tide-20160706.731/tsserver/tsserver.js:59653:11)
    at ts (/home/bhorsley/dotfiles/.emacs.d/.cask/24.5.1/elpa/tide-20160706.731/tsserver/tsserver.js:60648:7)
    at Object.<anonymous> (/home/bhorsley/dotfiles/.emacs.d/.cask/24.5.1/elpa/tide-20160706.731/tsserver/tsserver.js:60649:3)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
Info 2    response: {"seq":0,"type":"response","command":"syntacticDiagnosticsSync","request_seq":"1","success":false,"message":"Error processing request. No Project.\nError: No Project.\n    at Errors (/home/bhorsley/dotfiles/.emacs.d/.cask/24.5.1/elpa/tide-20160706.731/tsserver/tsserver.js:59651:32)\n    at ts.server.ts.server (/home/bhorsley/dotfiles/.emacs.d/.cask/24.5.1/elpa/tide-20160706.731/tsserver/tsserver.js:59653:11)\n    at ts (/home/bhorsley/dotfiles/.emacs.d/.cask/24.5.1/elpa/tide-20160706.731/tsserver/tsserver.js:60648:7)\n    at Object.<anonymous> (/home/bhorsley/dotfiles/.emacs.d/.cask/24.5.1/elpa/tide-20160706.731/tsserver/tsserver.js:60649:3)\n    at Module._compile (module.js:410:26)\n    at Object.Module._extensions..js (module.js:417:10)\n    at Module.load (module.js:344:32)\n    at Function.Module._load (module.js:301:12)\n    at Function.Module.runMain (module.js:442:10)\n    at startup (node.js:136:18)"}
Info 3    request: {"command":"semanticDiagnosticsSync","seq":"2","arguments":{"file":"\/home\/bhorsley\/Workspace\/tide-test\/main.ts"}}
Err 4     Exception on executing command {"command":"semanticDiagnosticsSync","seq":"2","arguments":{"file":"\/home\/bhorsley\/Workspace\/tide-test\/main.ts"}}:
No Project.
Error: No Project.
    at Errors (/home/bhorsley/dotfiles/.emacs.d/.cask/24.5.1/elpa/tide-20160706.731/tsserver/tsserver.js:59651:32)
    at ts.server.ts.server (/home/bhorsley/dotfiles/.emacs.d/.cask/24.5.1/elpa/tide-20160706.731/tsserver/tsserver.js:59653:11)
    at ts (/home/bhorsley/dotfiles/.emacs.d/.cask/24.5.1/elpa/tide-20160706.731/tsserver/tsserver.js:60648:7)
    at Object.<anonymous> (/home/bhorsley/dotfiles/.emacs.d/.cask/24.5.1/elpa/tide-20160706.731/tsserver/tsserver.js:60649:3)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
Info 5    response: {"seq":0,"type":"response","command":"semanticDiagnosticsSync","request_seq":"2","success":false,"message":"Error processing request. No Project.\nError: Noerror  Project.\n    at Errors (/home/bhorsley/dotfiles/.emacs.d/.cask/24.5.1/elpa/tide-20160706.731/tsserver/tsserver.js:59651:32)\n    at ts.server.ts.server (/home/bhorsley/dotfiles/.emacs.d/.cask/24.5.1/elpa/tide-20160706.731/tsserver/tsserver.js:59653:11)\n    at ts (/home/bhorsley/dotfiles/.emacs.d/.cask/24.5.1/elpa/tide-20160706.731/tsserver/tsserver.js:60648:7)\n    at Object.<anonymous> (/home/bhorsley/dotfiles/.emacs.d/.cask/24.5.1/elpa/tide-20160706.731/tsserver/tsserver.js:60649:3)\n    at Module._compile (module.js:410:26)\n    at Object.Module._extensions..js (module.js:417:10)\n    at Module.load (module.js:344:32)\n    at Function.Module._load (module.js:301:12)\n    at Function.Module.runMain (module.js:442:10)\n    at startup (node.js:136:18)"}

Starting a local copy of tsserver myself is causing the same exception when issuing the same command so I believe the problem is with the command that tide is sending?

$ node_modules/.bin/tsserver 
{"command":"syntacticDiagnosticsSync","seq":"1","arguments":{"file":"\/home\/bhorsley\/Workspace\/tide-test\/main.ts"}}
Content-Length: 865

{"seq":0,"type":"response","command":"syntacticDiagnosticsSync","request_seq":"1","success":false,"message":"Error processing request. No Project.\nError: No Project.\n    at Errors (/home/bhorsley/Workspace/tide-test/node_modules/typescript/lib/tsserver.js:49798:32)\n    at ts.server.ts.server (/home/bhorsley/Workspace/tide-test/node_modules/typescript/lib/tsserver.js:49800:11)\n    at ts (/home/bhorsley/Workspace/tide-test/node_modules/typescript/lib/tsserver.js:50774:7)\n    at Object.<anonymous> (/home/bhorsley/Workspace/tide-test/node_modules/typescript/lib/tsserver.js:50775:3)\n    at Module._compile (module.js:410:26)\n    at Object.Module._extensions..js (module.js:417:10)\n    at Module.load (module.js:344:32)\n    at Function.Module._load (module.js:301:12)\n    at Module.require (module.js:354:17)\n    at require (internal/module.js:12:17)"}

My knowledge of tsserver commands is limited so I don't know what further debugging I can do on this, but if there's any other info I can provide, let me know!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.