Giter Site home page Giter Site logo

Cannot start "deno lsp" about lsp-bridge HOT 7 CLOSED

finalclass avatar finalclass commented on July 2, 2024
Cannot start "deno lsp"

from lsp-bridge.

Comments (7)

finalclass avatar finalclass commented on July 2, 2024 1

I'm sorry for writing so late, but I was on vacation. I've tested the solution, and it works great. Thanks a lot!

Since when I write JS I always use deno, the lsp-bridge-get-single-lang-server-by-project function is very simple for me:

;; use deno for ts and tsx, for anything else  use defaults
(setq lsp-bridge-get-single-lang-server-by-project
      (lambda (project-path file-path)
	(when (or (string-suffix-p ".ts" file-path)
		  (string-suffix-p ".tsx" file-path))
	  "deno")))

from lsp-bridge.

manateelazycat avatar manateelazycat commented on July 2, 2024
(setq lsp-bridge-get-multi-lang-server-by-project
      (lambda (project-path filepath)
        ;; If typescript file include deno.land url, then use Deno LSP server.
        (save-excursion
          (when (string-equal (file-name-extension filepath) "ts")
            (dolist (buf (buffer-list))
              (when (string-equal (buffer-file-name buf) filepath)
                (with-current-buffer buf
                  (goto-char (point-min))
                  (when (search-forward-regexp (regexp-quote "from \"https://deno.land") nil t)
                    (return "deno")))))))))

from lsp-bridge.

finalclass avatar finalclass commented on July 2, 2024

This does not work for me because I use deno.jsonc for imports (as almost everyone that uses deno). Nevertheless, why my lambda function is not being called?

from lsp-bridge.

finalclass avatar finalclass commented on July 2, 2024

Moreover the method you provided will work only if you have deno.land imports. On any other file in a deno project it will fail. I'm able to tweak it properly however from my observation it's never called.

from lsp-bridge.

manateelazycat avatar manateelazycat commented on July 2, 2024

please upload test code, I will research it

from lsp-bridge.

finalclass avatar finalclass commented on July 2, 2024

image

main.ts

import { sum } from "./math.ts";

console.log(sum(2, 2));

math.ts

export function sum(a:number, b:number) : number {
    return a + b;
}

init.el

(use-package markdown-mode :ensure t)
(use-package yasnippet :ensure t)

(add-to-list 'load-path "/home/sel/.emacs.d/lsp-bridge")

(require 'yasnippet)
(yas-global-mode 1)

(require 'lsp-bridge)
(global-lsp-bridge-mode)

(use-package typescript-mode :ensure t)


(setq lsp-bridge-get-lang-server-by-project
      (lambda (project-path file-path)
	"deno"))

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-selected-packages '(typescript-mode yasnippet markdown-mode))
 '(safe-local-variable-values '((typescript-indent-offset . 2))))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
~$ emacs --version
GNU Emacs 29.2
Copyright (C) 2024 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
~$ uname -a
Linux rog 5.15.154-1-MANJARO #1 SMP PREEMPT Wed Apr 10 19:10:26 UTC 2024 x86_64 GNU/Linux
~$ deno --version
deno 1.39.1 (release, x86_64-unknown-linux-gnu)
v8 12.0.267.8
typescript 5.3.3

from lsp-bridge.

manateelazycat avatar manateelazycat commented on July 2, 2024
;; lsp-bridge first try `lsp-bridge--get-multi-lang-server-func', then try `lsp-bridge--get-single-lang-server-func'
;; So we need remove `ts' and `tsx' setting from default value of lsp-bridge-multi-lang-server-extension-list.
(setq lsp-bridge-multi-lang-server-extension-list
      (cl-remove-if (lambda (item)
                      (equal (car item) '("ts" "tsx")))
                    lsp-bridge-multi-lang-server-extension-list))

;; Last we customize `lsp-bridge-get-single-lang-server-by-project' to return `deno' lsp server name.
;; I recommand you write some code to compare project-path or file-path, return `deno' only if match target path.
(setq lsp-bridge-get-single-lang-server-by-project
      (lambda (project-path file-path)
	    "deno"))

from lsp-bridge.

Related Issues (20)

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.