-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow generic 'first line match' across all syntaxes #1600
Comments
This is very essential. Most config files don't have extension (e.g vimrc, .zshrc, .bashrc) and their format is typically defined by their first line as explained by OP. I hope this feature gets more traction. Also having this feature would make the integration of bat easier in TUI file managers. For example in vifm I have the following which passes the vifmrc ( fileviewer *.R,*.md,*.sh,*.py,*.yml,*.toml,*.el,*.ini,*.json,*rc
\ env -uCOLORTERM
\ bat
\ --force-colorization
\ --line-range=:%ph
\ --terminal-width=%pw
\ --wrap='never'
\ --pager='never'
\ --style='plain'
\ --tabs=2
\ %c |
Excuse me.
Then we use Thanks. |
I am very interested in this first-line match request. Have there been any further thoughts on this? |
actually vim modelines can occur at the last line of the file... And consider this common lisp & bash hybrid script, how would you highlight it? #!/bin/sh
#|-*- mode:lisp -*-|#
#|
exec ros -Q -- $0 "$@"
|#
(progn ;;init forms
(ros:ensure-asdf)
#+quicklisp(ql:quickload '() :silent t))
(defpackage :ros.script.test.3852975384
(:use :cl))
(in-package :ros.script.test.3852975384)
(defun main (&rest argv)
(declare (ignorable argv)))
;;; vim: set ft=lisp lisp:
|
Similar: #!/usr/bin/env bb
#_" -*- mode: clojure; -*-" |
Please implement this! |
I don't see much of bash here apart from the shebang, but that said, as far as I understand this thread is about syntax highlighting, and therefore we should focus only on what the user wants to read rather than how it should be executed. For this reason my suggestions are as follows:
So imho the code needs to check the first few lines and the last few lines of the given file (if it is not binary) for Vim, Emacs, and shebang, then apply the priorities. |
Suggested by @keith-hall in #160
The idea is to read the syntax from the first line of input, like a shebang, emacs syntax hint, or vim modeline.
Ideally this wouldn't have to literally be on the first line, but for technical/performance reasons it probably must.
The text was updated successfully, but these errors were encountered: