I’m pretty noob in this kakoune configuration thing.
I really like the editor, but in trying to add many interesting features, I lost the native syntax highlighting for HTML and CSS (or so I think).
Please, some guru help me understand my config file (which has no errors, by the way) and what I did wrong to loose that handy feature.
Here is my .kakrc
( which lives in ~/$HOME/.config/
)
####
## Source: https://github.com/JJK96/kakoune-config/blob/master/kakrc
####
# # # Colorscheme
colorscheme gruvbox-dark
# # # Change totally to a slightly different background color when in insert mode
# Colorschemes (where different background color is defined) are defined for user in ~/.config/kak/colors/
#
# You can use these two hooks for changing background color when entering INSERT mode
# With this approach, it is required to define a new colorscheme to be used in INSERT mode
#hook global ModeChange push:[^:]*:insert %{ colorscheme gruvbox-dark-INSERT-mode }
#hook global ModeChange pop:insert:.* %{ colorscheme gruvbox-dark }
#
# This is a another way…
# # Whenever a window switches to insert mode, override its Default face to have a red background
hook global ModeChange .*:insert %{ set-face window Default default,rgb:25234f }
# # Whenever a window leaves insert mode, remove its override of the Default face
hook global ModeChange .*:insert:.* %{ unset-face window Default }
#
# This is a third way to change background color only when in insert mode…
# (Use this or one of the two previuos hook options pair.)
#set-face global Default default,red
# # # Interface options
set-option global ui_options terminal_assistant=cat terminal_set_title=true
# # # Always keep one line and three columns displayed around the cursor
set-option global scrolloff 1,3
# # # Relative line numbers
hook global BufCreate .* %[
add-highlighter buffer/ number-lines -hlcursor -relative -min-digits 3
add-highlighter buffer/ wrap -word -indent
]
add-highlighter global/ show-matching
add-highlighter global/ wrap
# # # Indentation
set-option global tabstop 2
set-option global indentwidth 2
# # # Tabs to spaces
#hook global InsertChar \t %{
# exec -draft h@
#}
# To allow you to cycle through the completion candidates with <tab> and shift+<tab>
# (https://github.com/mawww/kakoune/issues/1327)
# (https://github.com/mawww/kakoune/wiki/Indentation-and-Tabulation#use-tab-for-both-indenting-and-completion)
#
hook global WinCreate .* %{
hook window InsertCompletionShow .* %{
map window insert <tab> <c-n>
map window insert <backtab> <c-p>
}
}
hook global WinCreate .* %{
hook window InsertCompletionHide .* %{
unmap window insert <tab> <c-n>
unmap window insert <backtab> <c-p>
}
}
# # # Clipboard interaction
hook global RegisterModified '"' %{ nop %sh{
printf %s "$kak_main_reg_dquote" | xsel --input --clipboard
}}
map global user P '!xsel --output --clipboard<ret>'
map global user p '<a-!>xsel --output --clipboard<ret>'
map global user R '|xsel --output --clipboard<ret>'
# How to use it
# y/d - yank/delete using internal clipboard AND system clipboard at once
# p - paste from internal clipboard
# ,p - paste after from system clipboard (, is default for user mode)
# ,P - paste before from system clipboard (, is default for user mode)
# ,R - replace selection from system clipboard (, is default for user mode)
# To paste with mouse middle-click
hook global RawKey <mouse:press:middle:.*> %{
exec !xclip<space>-o<ret>
}
# Not needed anymore:
#
# define-command paste %{
# evaluate-commands -save-regs ^ %{
# #Paste
# execute-keys "!pbpaste<ret>"
# #Select
# execute-keys uU
# #Save selection
# execute-keys -save-regs "" Z
# try %{
# #Remove cariage return before newline
# execute-keys "s\r\n<ret>hd"
# }
# try %{
# #Replace cariage return elsewhere with newline
# execute-keys "zs\r<ret>r<return>"
# }
# #Restore selection
# execute-keys z
# }
# }
# map global user p -docstring 'paste from clipboard' ': paste<ret>'
# map global user y -docstring 'copy to clipboard' '<a-|>pbcopy<ret>'
# map global user d -docstring 'cut to clipboard' '|pbcopy<ret>'
#map -docstring "yank the selection into the clipboard" global user y "<a-|> xsel -i<ret>"
#map -docstring "paste the clipboard" global user p "<a-!> xsel<ret>"
#map global user y '<a-|>xsel -i -b<ret>'
#hook global RegisterModified '"' %{ nop %sh{
# printf %s "$kak_main_reg_dquote" | xsel --input --clipboard
#}
# # # Use ripgrep instead of grep
set-option global grepcmd 'rg -Hn --no-heading'
# # # Comment lines and blocks
define-command comment %{
try %{
execute-keys _
comment-block
} catch comment-line
}
# comment lines
map global user c -docstring 'comment lines' %{: comment<ret>}
# # # To avoid escape key
# Use jk to exit insert mode
hook global InsertChar k %{ try %{
exec -draft hH <a-k>jk<ret> d
exec <esc>
}}
# # # Buffers management
# # # https://github.com/Delapouite/kakoune-buffers
hook global WinDisplay .* info-buffers
# Keyboard mappings
map global user b ':enter-buffers-mode<ret>' -docstring 'buffers…'
map global user B ':enter-user-mode -lock buffers<ret>' -docstring 'buffers (lock)…'
# Aliases
alias global bd delete-buffer
alias global bf buffer-first
alias global bl buffer-last
alias global bo buffer-only
alias global bo! buffer-only-force
# Remapping of q (for macros) to hadling buffers…
# …ciao macros…
map global normal ^ q
map global normal <a-^> Q
map global normal q b
map global normal Q B
map global normal <a-q> <a-b>
map global normal <a-Q> <a-B>
map global normal b ':enter-buffers-mode<ret>' -docstring 'buffers…'
map global normal B ':enter-user-mode -lock buffers<ret>' -docstring 'buffers (lock)…'