This is a thread for smaller, miscellaneous items that might not warrant a full post on their own.
See this search for previous “Weekly Tips, Tricks, &c.” Threads.
Don’t feel constrained in regards to what you post, just keep your post vaguely, generally on the topic of emacs.
I’m an Emacs noob trying to set up an environment for working with React. I have trouble with getting the LS to not mark the embedded templates red in .tsx files, such as this:
import React from 'react'; import ProjectsPage from './projects/ProjectsPage'; function App() { return ; } export default App;
I followed a few steps of the guide [https://vxlabs.com/2022/06/12/typescript-development-with-emacs-tree-sitter-and-lsp-in-2022/](TypeScript development with Emacs, tree-sitter and LSP in 2022) to set up Eglot and a derived mode that specifies the TSX in the name.
This is in my init.el:
(use-package eglot :ensure t) (define-derived-mode typescriptreact-mode typescript-mode "TypeScript TSX") (add-to-list 'auto-mode-alist '("\\.tsx\\'" . typescriptreact-mode)) (use-package typescript-mode :after tree-sitter smart-parens :config (add-to-list 'tree-sitter-major-mode-language-alist '(typescriptreact-mode . tsx)))
The
typescriptreact-mode
is active when i enter a .tsx-file and Eglot connects to the typescript-language-server (version 4.0 is on my path), but it doesn’t seem to tell the LS that this extended syntax should be used. What am I missing?Not sure if anyone post this, but I just found a way to autofill (async-) shell-command with latest run command from history with 2 simple lines of code:
(advice-add #'read-shell-command :filter-args #'(lambda(args) (list (car args) (car shell-command-history))))
I’m still learning lisp, so any improvement are welcome.
This was a great little ergonomic improvement, and thanks for taking us on that journey!
My final version is in my config now. The only improvements are skipping the most recent command when scrolling back through history (a nice improvement IMO) and some probably unnecessary refactoring.
Thanks for finding that advice solution, which is like 98% of my version. : )
I like your version, i didn’t notice the navigation duplication before, and that
cl-destructuring-bind
is a life saver.I’m glad it helps someone
I want to praise the package mini-mode-line, which allows you to collapse your mode-line into your echo area. Saves you some screen estate (especially in multi-window setups), and also makes it easy to toggle the modeline on and off by playing with the format.
There are different ways to do all of that, sure, but I really like the way this package handles all of that—which is basically all I want out of a modeline. Discovering this package last month has been a nice change in my setup.
Thanks, u/kiennq!
I’ll try this out, thank you for bringing it up!