Files
neovim/runtime/syntax/sshknownhosts.vim
zeertzjq 84cd87908e vim-patch:9.2.0742: filetype: SSH keys and related filetypes not recognized (#40469)
Problem:  filetype: SSH keys and related filetypes not recognized
Solution: Detect sshpublickey, sshknownhosts sshauthorizedkeys and
          sshallowedsigners filetypes, add syntax scripts for those
          filetypes (Fionn Fitzmaurice)

This adds syntax highlighting for SSH public keys, as well as related
filetypes derived from this (SSH authorized keys, SSH known hosts and
SSH allowed signers).

Also add filetype detection based on the path and name.

closes: vim/vim#20635

6e66ebc0fd

Co-authored-by: Fionn Fitzmaurice <git@fionn.computer>
2026-06-28 23:48:17 +00:00

28 lines
1.2 KiB
VimL

" Vim syntax file
" Language: OpenSSH known hosts file
" Author: Fionn Fitzmaurice (github.com/fionn)
" Maintainer: Fionn Fitzmaurice (github.com/fionn)
" License: Vim & Apache 2.0
if exists("b:current_syntax")
finish
endif
runtime! syntax/sshpublickey.vim
syn match sshKnownHostsMarker "^@cert-authority\>" nextgroup=sshKnownHostsHostname,sshKnownHostsHashedHostname skipwhite
syn match sshKnownHostsMarker "^@revoked\>" nextgroup=sshKnownHostsHostname,sshKnownHostsHashedHostname skipwhite
syn match sshKnownHostsHostname "!\?[a-zA-Z0-9.*-]\+" nextgroup=sshKnownHostsHostnameSeparator,sshKeyType skipwhite
syn match sshKnownHostsHostname "!\?\[[a-zA-Z0-9.*-]\+\]:[0-9]\{1,5}" nextgroup=sshKnownHostsHostnameSeparator,sshKeyType skipwhite
syn match sshKnownHostsHostnameSeparator "," contained nextgroup=sshKnownHostsHostname
syn match sshKnownHostsHashedHostname "|1|[a-zA-Z0-9/+]\+=\{,2}|[a-zA-Z0-9/+]\+=\{,2}" nextgroup=sshKeyType skipwhite
hi def link sshKnownHostsMarker Statement
hi def link sshKnownHostsHostname Identifier
hi def link sshKnownHostsHostnameSeparator Punctuation
hi def link sshKnownHostsHashedHostname Identifier
let b:current_syntax = "sshknownhosts"