3 ms·
For reference, here are my versions ________________ M-x emacs-version GNU Emacs 29.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Versio
by srhtftw 3y ago
For reference, here are my versions
________________ M-x emacs-version
GNU Emacs 29.1 (build 1, x86_64-apple-darwin18.7.0,
NS appkit-1671.60 Version 10.14.6 (Build 18G9323)) of 2023-07-30
________________ M-x describe-mode (for C++)
Minor modes enabled in this buffer: Font-Lock Tree-Sitter-Hl Tree-Sitter
The major mode is C++//l mode defined in cc-mode.el:
Major mode for editing C++ code.
Using CC Mode version 5.35.2
________________ M-x describe-mode (for ts)
Minor modes enabled in this buffer: Font-Lock Tree-Sitter-Hl Tree-Sitter
The major mode is TypeScript mode defined in typescript-mode.el:
Major mode for editing typescript.
;;; typescript-mode.el --- Major mode for editing typescript
;; URL: http://github.com/ananthakumaran/typescript.el
;; Version: 0.4
;; Keywords: typescript languages
;; Package-Requires: ((emacs "24.3"))
________________ os
% uname -srm
Darwin 19.6.0 x86_64
% sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.7
BuildVersion: 19H15
- G3rn0ti 3y agoSorry, was AFK over the weekend. > Minor modes enabled in this buffer: Font-Lock Tree-Sitter-Hl Tree-Sitter > The major mode is TypeScript mode defined in typescript-mode.el: > Major mode for editing typescript. This actually indicates that you are in fact using some tree sitter extension for doing "font-locking". Do you happen to have installed "elisp-tree-sitter" in the past? Perhaps this setup has some bugs. Or your font-locking is still running regexes in your mix. This is how typescript mode looks for me using Emacs 29.1's built-in tree sitter support: Minor modes enabled in this buffer: Auto-Revert Auto-Save Company Eldoc Flycheck Flyspell Font-Lock Lsp-Headerline-Breadcrumb Lsp-Modeline-Workspace-Status Lsp-Ui-Doc Lsp-Ui Lsp-Ui-Sideline Yas The major mode is TypeScript mode defined in typescript-ts-mode.el: Major mode for editing TypeScript. (I am also running "lsp-mode.el" so there are more minor modes running than perhaps in your case.) So, I would remove any tree sitter extension you may have installed in the past. Then to activate the new "typescript-ts-mode" you need to do the following: 1. Clone this repository: https://github.com/casouri/tree-sitter-module/ https://github.com/casouri/tree-sitter-module/ 2. run "./build typescript" (you'll need build-essentials and a C++ compile but I gathered you are programming in C++, so) 3. Copy the resulting shared library "dist/libtree-sitter-typescript.so" into "~/.emacs.d/tree-sitter/". 4. Open a random typescript file and try "M-x typescript-ts-mode" which should not give you any error but nice syntax highlighting. 5. Of course, you'll need some tweaking to make it your default. Basically, you'll have to add "'typescript-ts-mode" to your "'auto-mode-list". You'll have to do the same for your C++ setup. U̶n̶f̶o̶r̶t̶u̶n̶a̶t̶e̶l̶y̶,̶ ̶t̶h̶e̶ ̶c̶o̶n̶v̶e̶n̶i̶e̶n̶c̶e̶ ̶"̶t̶r̶e̶e̶-̶s̶i̶t̶t̶e̶r̶-̶m̶o̶d̶u̶l̶e̶"̶ ̶b̶u̶i̶l̶d̶ ̶s̶c̶r̶i̶p̶t̶ ̶d̶o̶e̶s̶ ̶n̶o̶t̶ ̶s̶u̶p̶p̶o̶r̶t̶ ̶C̶+̶+̶ ̶o̶u̶t̶ ̶o̶f̶ ̶t̶h̶e̶ ̶b̶o̶x̶.̶ ̶B̶u̶t̶ ̶i̶t̶ ̶d̶o̶e̶s̶ ̶n̶o̶t̶ ̶l̶o̶o̶k̶ ̶c̶o̶m̶p̶l̶i̶c̶a̶t̶e̶d̶ ̶t̶o̶ ̶e̶x̶t̶e̶n̶d̶ ̶i̶t̶ ̶f̶o̶r̶ ̶y̶o̶u̶r̶ ̶p̶u̶r̶p̶o̶s̶e̶s̶.̶ Nonsense, it is supported: Just run "./build cpp". You also seem to need "./build c". This way, I was able to activate the new C++ treesitter mode. If you do not want to go ahead and migrate to built-in treesitter yet -- as you see it's still a bit fiddly to setup as it is brand new -- I would tackle your C++ performance problem first by using Emacs' profiler: 1. M-x profiler-start (select "CPU") 2. Open your C++ file slowing your Emacs down. 3. M-x profiler-stop 4. M-x profiler-report and see what it gives you. Perhaps post an issue with the Emacs maintainers and they can give a clue where your issue comes from. But usually something like this is caused by a run-a-way regex. Good luck!
- srhtftw 3y agoThank you for the recommendation. I will look into building my own tree sitter grammars using https://github.com/casouri/tree-sitter-module https://github.com/casouri/tree-sitter-module as you suggest. Some time ago I followed this guide https://vxlabs.com/2022/06/12/typescript-development-with-emacs-tree-sitter-and-lsp-in-2022 https://vxlabs.com/2022/06/12/typescript-development-with-em... and added this to my .emacs (use-package tree-sitter :ensure t :config ;; activate tree-sitter on any buffer containing code for which it has a parser available (global-tree-sitter-mode) ;; you can easily see the difference tree-sitter-hl-mode makes for python, ts or tsx ;; by switching on and off (add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode)) (use-package tree-sitter-langs :ensure t :after tree-sitter) Regarding C++, I tried a simpler experiment starting emacs with % open -n -a Emacs --args "-q" and I think my C++ slowness issue is due to fontlock https://www.gnu.org/software/emacs/manual/html_node/emacs/Font-Lock.html https://www.gnu.org/software/emacs/manual/html_node/emacs/Fo... Even without a startup file, I can't open https://github.com/ASDAlexander77/TypeScriptCompiler/blob/main/tsc/lib/TypeScript/MLIRGen.cpp https://github.com/ASDAlexander77/TypeScriptCompiler/blob/ma... and scroll through the file unless I also manually do ESC : (global-font-lock-mode 0) I'm sorry if I gave the impression I'm a regular C++ developer. I only use it occasionally. I just happened to remember finding myself unable to use Emacs for that particular file.