Comments (7)
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.
(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.
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.
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.
please upload test code, I will research it
from lsp-bridge.
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.
;; 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)
- java 多个工程代码跳转的问题 HOT 5
- markdown default lang sever is incorrect HOT 1
- [Feature-Request]/Question: Tree-like view of symbols from lsp-bridge HOT 3
- vscode-html-language-server日志返回candidates为0 HOT 8
- diagnostic功能无法显示整个project的异常 HOT 3
- 在启用auto-insert-mode之后,在打开新.sh文件时会出错 HOT 1
- How to setup for lisp mode? HOT 2
- Tailwindcss and Eslint working with javascriptreact but not typescriptreact. HOT 1
- Support macro expand for rust HOT 6
- auto-completed content comes to end of the line HOT 6
- [Question] Is it possible to enable plugins for pylsp? HOT 1
- 本地文件跳转报错: Forbidden reentrant call of Tramp HOT 3
- Build a multi-thread backend for CAPF
- completion not working on windows with doomemacs HOT 2
- Submit to GNU ELPA HOT 1
- Rust mode does not show expected diagnostic info HOT 1
- Win10行安装后报错: No compression program defined HOT 1
- completion word from a file HOT 4
- basedpyright_ruff issue HOT 1
- dart中import无法补全库名称 HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lsp-bridge.