"---------------------------------------------------------------------------
" Shougo's .vimrc
"---------------------------------------------------------------------------
" profile start profile.txt
" profile file ~/work/*
" profile file ~/.cache/dpp/nvim/state.vim
" profile func dpp#*

if &compatible
  set nocompatible
endif

" Set augroup.
augroup MyAutoCmd
  autocmd!
  autocmd FileType,Syntax,BufNewFile,BufNew,BufRead *?
        \ call vimrc#on_filetype()
augroup END

" Minimal options
if '+termguicolors'->exists() && !has('gui_running')
  set termguicolors
endif
set shortmess=aTIcFoOsSW showtabline=0 laststatus=0
set noruler noshowcmd noshowmode

" Disable statusline.
set statusline=%{' '->repeat(winwidth(0)/2)}
"if has('nvim')
"  set statusline=%{'─'->repeat(&columns)}
"endif

" Set laststatus=3 automatically
"if has('nvim')
"  autocmd MyAutoCmd WinEnter,CursorHold,CursorHoldI *
"        \ : if winlayout()[1]->type() != v:t_list
"        \ |   set laststatus=0
"        \ | else
"        \ |   set laststatus=3
"        \ | endif
"endif

" Height of the command line.
try
  set cmdheight=0

  " For recording messages
  autocmd MyAutoCmd CmdlineEnter,RecordingEnter * set cmdheight=1
  autocmd MyAutoCmd CmdlineLeave,RecordingLeave * set cmdheight=0
catch
  set cmdheight=1
endtry

" Show title.
set title titlelen=95
" Title string.
let &g:titlestring = [
      \   "%{'%:p:~:.'->expand()}",
      \   "%<\(%{getcwd()->fnamemodify(':~')}\)",
      \   "%(%y%m%r%)",
      \ ]->join()

if has('nvim')
  " Use cursor shape feature
  set guicursor=n-v-c:block-Cursor/lCursor-blinkon0,
        \i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor

  " Use new loader
  lua if vim.loader then vim.loader.enable() end
endif

" NOTE: Colorscheme must be initialized in the first.
colorscheme candy

" Use English interface.
language message C

if '~/.secret_vimrc'->expand()->filereadable()
  source ~/.secret_vimrc
endif

const base_path = '<sfile>'->expand()->fnamemodify(':h')

execute 'source' base_path .. '/dpp.vim'

if !has('nvim')
  execute 'source' base_path .. '/vim9.rc.vim'
endif

"---------------------------------------------------------------------------

if !argv()->empty()
  autocmd MyAutoCmd CursorHold * call vimrc#on_filetype()
endif

set secure