Comments (1)
I really think emacs needs better support for just highlighting an arbitrary string. Different packages keep re-implementing this and none really reach the same quality as just writing them into a buffer and running font-lock on it.
Personally I think org-mode src block highlighting is the best. It even supports tree-sitter faces which makes the highlighted code identical to if I had just written it out myslef.
Here's a way to make ggtags use org for syntax highlighting. It should work reasonably well until we find a better implementation for ggtags itself.
(require 'org-src)
(defun ggtags-fontify-code-with-org+ (code &optional mode)
(or mode (setq mode major-mode))
(if (stringp code)
(let* ((lang (s-chop-suffix "-mode" (symbol-name mode)))
;; Fallback to default-face not org-block-face.
(org-src-block-faces `((,lang . (default)))))
(with-temp-buffer
(insert code)
(org-src-font-lock-fontify-block lang (point-min) (point-max))
(buffer-substring (point-min) (point-max))))
code))
(advice-add #'ggtags-fontify-code :override #'ggtags-fontify-code-with-org+)
from ggtags.
Related Issues (20)
- file path is shortened in the output buffer HOT 2
- Tag navigation and compilation mode HOT 1
- How to use this gtags-cscope feature from ggtags.el
- CPU is pinned to 100%, with excessive gtags processes spawned HOT 6
- ‘global’ non-zero exit: sh: global: command not found HOT 2
- POSIX realpath required
- wrong-type-argument error on compilation-auto-jump timer
- ggtags causes company-capf to fail when GTAGS doesn't exist
- ggtags doesn't work with xref in Emacs 27.2 since latest update HOT 3
- GTAGSLIBPATH not searched HOT 1
- `ggtags-fontify-code` should be called optionally HOT 2
- With tramp: Error running timer ‘compilation-auto-jump’: (wrong-type-argument stringp nil) HOT 5
- 'xref-find-definitions' problem in symbolic link directory HOT 6
- xref-pop-marker-stack doesn't return to previous location HOT 1
- Use default gtags backend unless GTAGSLABEL is set
- Enhancement: Use Emacs' sqlite API (built-in or via module)
- Make integration with xref and capf user configurable
- Compile warnings with latest emacs master
- final message interpreted as a match HOT 2
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 ggtags.