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)
- 使用lsp-bridge-semantic-tokens-global-scope-face后,C++中的宏和函数的颜色无法区分开 HOT 9
- Rust中函数名不显示 HOT 1
- C++自己写的头文件函数名不显示,标准库可以 HOT 6
- Incorrect response to `window/workDoneProgress/create` HOT 2
- paramiko.ssh_exception.PasswordRequiredException: Private key file is encrypted HOT 3
- 补全自动修改窗口位置 HOT 3
- `lsp-bridge` clogging `org-babel-tangle` when enabled HOT 2
- Dynamically set up `lsp-bridge-get-single-lang-server-by-project` HOT 3
- rust remote server 失败,可能是在远程主机没有启动 tabnine HOT 7
- react jsx 中不支持 tailwindcss HOT 3
- semantic-tokens 渲染modifiers时能否支持combine和override混用 HOT 7
- 调用 multi-server-function的时候,如果当前project 没有git init,则会报错,建议设置当前目录作为缺省值并且打印message提醒一下用户 HOT 1
- `lsp-bridge-find-def` with `pyright` takes to stub file (`.pyi`) instead of code (`.py`). HOT 1
- When I open the vue project, ts doesn't recognize my directory HOT 5
- vue模式下跳转定义文件,第二次就失败了 HOT 4
- Document how to use lsp-bridge with python installed via pyenv HOT 1
- An error occurred when I use lap-bridge to edit a file remotely HOT 4
- 使用最新代码(commitid: 1f47c8fb),js 无法补全 HOT 1
- 刚装上,同时出现了 YASnippet 和 lsp 的补全列表,怎么去选中 YASnippet 的候选项了 HOT 2
- Probably a typo in multiserver/qmlls_javascript.json HOT 1
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.