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

Cant completion on react project #1385

Closed
glepnir opened this issue Feb 6, 2020 · 3 comments
Closed

Cant completion on react project #1385

glepnir opened this issue Feb 6, 2020 · 3 comments

Comments

@glepnir
Copy link

glepnir commented Feb 6, 2020

@yyoncho hi , I dones't get any completion items on react project,use javascript-typescript-langserver,It works well on a js project , but cant work on react ,like this pic.
image

(repo lsp-mode
  :commands (lsp-install-server lsp lsp-deferred)
  :init
  (setq lsp-session-file (concat supremacs-etc-dir "lsp-session")
        lsp-prefer-flymake nil
        lsp-auto-guess-root t
        lsp-keep-workspace-alive nil)
         ;; For `lsp-clients'
  (setq lsp-server-install-dir (concat supremacs-etc-dir "lsp/")
        lsp-groovy-server-install-dir (concat lsp-server-install-dir "lsp-groovy/")
        lsp-intelephense-storage-path (concat supremacs-cache-dir "lsp-intelephense/"))
  :config
  (when (and lsp-auto-configure lsp-auto-require-clients)
    (require 'lsp-clients)))

(repo lsp-ui
  :hook (lsp-mode . lsp-ui-mode)
  :config
  (setq lsp-prefer-flymake nil
        lsp-ui-doc-max-height 15
        lsp-ui-doc-max-width 100
        lsp-ui-sideline-enable nil
        lsp-ui-doc-include-signature t
        lsp-ui-sideline-ignore-duplicate t
        lsp-ui-doc-enable nil))

(use-package js2-mode
  :mode "\\.m?js\\'"
  :interpreter "node"
  :commands js2-line-break
  :config
  (setq js-chain-indent t
        ;; Don't mishighlight shebang lines
        js2-skip-preprocessor-directives t
        ;; let flycheck handle this
        js2-mode-show-parse-errors nil
        js2-mode-show-strict-warnings nil
        ;; Flycheck provides these features, so disable them: conflicting with
        ;; the eslint settings.
        js2-strict-trailing-comma-warning nil
        js2-strict-missing-semi-warning nil
        ;; maximum fontification
        js2-highlight-level 3
        js2-highlight-external-variables t
        js2-idle-timer-delay 0.1)

  (add-hook 'js2-mode-hook #'rainbow-delimiters-mode)
  (add-hook 'js2-mode-hook #'lsp-deferred))

(use-package typescript-mode
  :defer t
  :mode ("\\.ts[x]\\'" . typescript-mode)
  :config
  (add-hook 'typescript-mode-hook #'rainbow-delimiters-mode)
  (add-hook 'typescript-mode-hook #'lsp-deferred))
(use-package rjsx-mode
  :defer t
  :mode "components/.+\\.js$"
  :init
  (defun +javascript-jsx-file-p ()
    "Detect React or preact imports early in the file."
    (and buffer-file-name
         (string= (file-name-extension buffer-file-name) "js")
         (re-search-forward "\\(^\\s-*import +React\\|\\( from \\|require(\\)[\"']p?react\\)"
                            magic-mode-regexp-match-limit t)
         (progn (goto-char (match-beginning 1))
                (not (sp-point-in-string-or-comment)))))
  (add-to-list 'magic-mode-alist '(+javascript-jsx-file-p . rjsx-mode)))

(add-hook 'rsjx-mode-hook
          (lambda ()
            (setq mode-name "React")))

(add-hook 'rsjx-mode-hook #'lsp-deferred)

log buffer found this Buffer switched - ignoring response. Method textDocument/completion

Command "/usr/local/bin/javascript-typescript-stdio" is present on the path.
Command "/usr/local/bin/javascript-typescript-stdio" is present on the path.
Found the following clients for /Users/stephen/gin-admin-react/src/models/login.js: (server-id jsts-ls, priority -3)
The following clients were selected based on priority: (server-id jsts-ls, priority -3)
Found package file:///Users/stephen/gin-admin-react/package.json
Found package file:///Users/stephen/gin-admin-react/package.json
Command "/usr/local/bin/javascript-typescript-stdio" is present on the path.
Command "/usr/local/bin/javascript-typescript-stdio" is present on the path.
Found the following clients for /Users/stephen/gin-admin-react/src/components/PageHeader/index.js: (server-id jsts-ls, priority -3)
The following clients were selected based on priority: (server-id jsts-ls, priority -3)
Buffer switched - ignoring response. Method textDocument/completion
Buffer switched - ignoring response. Method textDocument/completion
Buffer switched - ignoring response. Method textDocument/completion
@yyoncho
Copy link
Member

yyoncho commented Feb 6, 2020

Can you provide a test project? IMO the language server fails in this project. I would recommend you to switch to ts-ls server and follow #1350 instructions.

@glepnir
Copy link
Author

glepnir commented Feb 7, 2020

@yyoncho thanks for reply , It works on ts-ls server . but i cant get any parens when completion item is a method .. Its a problem of typescript-language-server?
image

@yyoncho
Copy link
Member

yyoncho commented Feb 8, 2020

@yyoncho thanks for reply , It works on ts-ls server . but i cant get any parens when completion item is a method .. Its a problem of typescript-language-server?

This is how ts-ls works. Closing since there is nothing to fix on lsp-mode side.

@yyoncho yyoncho closed this as completed Feb 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants