""" Map leader to space ---------------------
let mapleader=" "

""" Plugins  --------------------------------
set surround
set commentary
set NERDTree

""" Common settings -------------------------
set showmode
set so=5
set incsearch
set nu
set relativenumber
set number

""" Which-Key
set which-key
set timeoutlen=5000

""" Idea specific settings ------------------
set ideajoin

""" Mappings --------------------------------
"" Quick action
let g:WhichKeyDesc_quick_action = '<leader>q Quick action'
map <leader>q <Action>(ShowIntentionActions)

"" Refactor binds
let g:WhichKeyDesc_inline = '<leader>i Inline'
map <leader>i <Action>(Inline)

let g:WhichKeyDesc_extract = '<leader>e Extract'
let g:WhichKeyDesc_extract_variable = '<leader>ev Extract variable'
map <leader>ev <Action>(IntroduceVariable)
let g:WhichKeyDesc_extract_constant = '<leader>ec Extract constant'
map <leader>ec <Action>(IntroduceConstant)
let g:WhichKeyDesc_extract_field = '<leader>ef Extract field'
map <leader>ef <Action>(IntroduceField)
let g:WhichKeyDesc_extract_parameter = '<leader>ep Extract parameter'
map <leader>ep <Action>(IntroduceParameter)
let g:WhichKeyDesc_extract_method = '<leader>em Extract method'
map <leader>em <Action>(ExtractMethod)

let g:WhichKeyDesc_rename = '<leader>r Rename'
map <leader>r <Action>(RenameElement)

"" Navigation
let g:WhichKeyDesc_prev_buffer = '[b Previous buffer'
map [b <Action>(PreviousTab)
let g:WhichKeyDesc_next_buffer = ']b Next buffer'
map ]b <Action>(NextTab)
let g:WhichKeyDesc_prev_problem = '[x Previous problem'
map [x <Action>(PreviousOccurence)
let g:WhichKeyDesc_next_problem = ']x Next problem'
map ]x <Action>(NextOccurence)


let g:WhichKeyDesc_goto_impl = 'gI Goto implementation'
map gI <Action>(GotoImplementation)
let g:WhichKeyDesc_goto_type = 'gt Goto type declaration'
map gt <Action>(GotoTypeDeclaration)

"" Other
let g:WhichKeyDesc_terminal = '<leader>t Terminal'
map <leader>t <Action>(ActivateTerminalToolWindow)
map = <Action>(ReformatCode)

"" Folding
let g:WhichKeyDesc_folding = 'z Folding'
let g:WhichKeyDesc_folding_toggle = 'za Toggle fold'
map za <Action>(ExpandCollapseToggleAction)

let g:WhichKeyDesc_folding_expand = 'zr Fold less'
map zr <Action>(ExpandRegion)
let g:WhichKeyDesc_folding_collapse = 'zR Open all folds'
map zR <Action>(ExpandAllRegions)
let g:WhichKeyDesc_folding_collapse = 'zm Fold more'
map zm <Action>(CollapseRegion)
let g:WhichKeyDesc_folding_collapse = 'zM Close all folds'
map zM <Action>(CollapseAllRegions)

let g:WhichKeyDesc_folding_collapse_doc = 'zc Collapse doc comments'
map zc <Action>(CollapseDocComments)
let g:WhichKeyDesc_folding_expand_doc = 'zC Expand doc comments'
map zC <Action>(ExpandDocComments)

let g:WhichKeyDesc_folding_expand_level_one = 'z1 Expand all to level 1'
map z1 <Action>(ExpandAllToLevel1)
let g:WhichKeyDesc_folding_expand_level_two = 'z2 Expand all to level 2'
map z2 <Action>(ExpandAllToLevel2)
let g:WhichKeyDesc_folding_expand_level_three = 'z3 Expand all to level 3'
map z3 <Action>(ExpandAllToLevel3)
let g:WhichKeyDesc_folding_expand_level_four = 'z4 Expand all to level 4'
map z4 <Action>(ExpandAllToLevel4)
