colorscheme gruvbox-dark

# Use 4 spaces for indentation.
# indentwidth controls Kakoune's indentation commands; tabstop controls display width.
set-option global tabstop 4
set-option global indentwidth 4
set-option global makecmd 'bash build.sh'

map global user n :make-next-error<ret>
map global user p :make-previous-error<ret>

# Toggle line comments for the current selection/line.
map global user / ': comment-line<ret>'

# Kakoune does not have a Vim-style 'expandtab' option. Make a literal Tab key
# insert four spaces instead of a tab character while in insert mode.
map global insert <tab> '<space><space><space><space>'

hook global InsertChar j %{ try %{
  exec -draft hH <a-k>jj<ret> d
  exec -with-hooks <esc>
}}
evaluate-commands %sh{
    if [ -n "${WAYLAND_DISPLAY:-}" ] && command -v wl-copy >/dev/null 2>&1 && command -v wl-paste >/dev/null 2>&1; then
        printf %s "
hook global RegisterModified '\"' %{ nop %reg{dquote} %sh{
    printf %s \"\$kak_main_reg_dquote\" | wl-copy > /dev/null 2>&1 &
}}

define-command -hidden paste-system-after %{
    evaluate-commands -save-regs '\"' %{
        set-register dquote %sh{ wl-paste --no-newline 2>/dev/null }
        execute-keys p
    }
}

define-command -hidden paste-system-before %{
    evaluate-commands -save-regs '\"' %{
        set-register dquote %sh{ wl-paste --no-newline 2>/dev/null }
        execute-keys P
    }
}

map global normal p ': paste-system-after<ret>'
map global normal P ': paste-system-before<ret>'
"
    fi
}

add-highlighter global/ number-lines
