forked from luna/vim-rana-local
new WakaTimeApiKey command to edit api key within Vim
This commit is contained in:
parent
eb862c880a
commit
d350a97b72
1 changed files with 17 additions and 6 deletions
|
@ -93,8 +93,7 @@ let s:VERSION = '4.0.15'
|
||||||
let found_api_key = s:true
|
let found_api_key = s:true
|
||||||
endif
|
endif
|
||||||
if !found_api_key
|
if !found_api_key
|
||||||
let key = input("[WakaTime] Enter your wakatime.com api key: ")
|
call s:PromptForApiKey()
|
||||||
call s:SetIniSetting('settings', 'api_key', key)
|
|
||||||
echo "[WakaTime] Setup complete! Visit https://wakatime.com to view your coding activity."
|
echo "[WakaTime] Setup complete! Visit https://wakatime.com to view your coding activity."
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -143,20 +142,20 @@ let s:VERSION = '4.0.15'
|
||||||
let lines = readfile(s:config_file)
|
let lines = readfile(s:config_file)
|
||||||
let currentSection = ''
|
let currentSection = ''
|
||||||
for line in lines
|
for line in lines
|
||||||
let line = s:StripWhitespace(line)
|
let entry = s:StripWhitespace(line)
|
||||||
if matchstr(line, '^\[') != '' && matchstr(line, '\]$') != ''
|
if matchstr(entry, '^\[') != '' && matchstr(entry, '\]$') != ''
|
||||||
if currentSection == a:section && !keyFound
|
if currentSection == a:section && !keyFound
|
||||||
let output = output + [join([a:key, a:val], '=')]
|
let output = output + [join([a:key, a:val], '=')]
|
||||||
let keyFound = s:true
|
let keyFound = s:true
|
||||||
endif
|
endif
|
||||||
let currentSection = substitute(line, '^\[\(.\{-}\)\]$', '\1', '')
|
let currentSection = substitute(entry, '^\[\(.\{-}\)\]$', '\1', '')
|
||||||
let output = output + [line]
|
let output = output + [line]
|
||||||
if currentSection == a:section
|
if currentSection == a:section
|
||||||
let sectionFound = s:true
|
let sectionFound = s:true
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
if currentSection == a:section
|
if currentSection == a:section
|
||||||
let group = split(line, '=')
|
let group = split(entry, '=')
|
||||||
if len(group) == 2 && s:StripWhitespace(group[0]) == a:key
|
if len(group) == 2 && s:StripWhitespace(group[0]) == a:key
|
||||||
let output = output + [join([a:key, a:val], '=')]
|
let output = output + [join([a:key, a:val], '=')]
|
||||||
let keyFound = s:true
|
let keyFound = s:true
|
||||||
|
@ -280,6 +279,17 @@ let s:VERSION = '4.0.15'
|
||||||
return s:false
|
return s:false
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:PromptForApiKey()
|
||||||
|
let api_key = s:false
|
||||||
|
let api_key = s:GetIniSetting('settings', 'api_key')
|
||||||
|
if api_key == ''
|
||||||
|
let api_key = s:GetIniSetting('settings', 'apikey')
|
||||||
|
endif
|
||||||
|
|
||||||
|
let api_key = input("[WakaTime] Enter your wakatime.com api key: ", api_key)
|
||||||
|
call s:SetIniSetting('settings', 'api_key', api_key)
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:EnableDebugMode()
|
function! s:EnableDebugMode()
|
||||||
call s:SetIniSetting('settings', 'debug', 'true')
|
call s:SetIniSetting('settings', 'debug', 'true')
|
||||||
let s:is_debug_mode_on = s:true
|
let s:is_debug_mode_on = s:true
|
||||||
|
@ -330,6 +340,7 @@ let s:VERSION = '4.0.15'
|
||||||
|
|
||||||
" Plugin Commands {{{
|
" Plugin Commands {{{
|
||||||
|
|
||||||
|
:command -nargs=0 WakaTimeApiKey call s:PromptForApiKey()
|
||||||
:command -nargs=0 WakaTimeDebugEnable call s:EnableDebugMode()
|
:command -nargs=0 WakaTimeDebugEnable call s:EnableDebugMode()
|
||||||
:command -nargs=0 WakaTimeDebugDisable call s:DisableDebugMode()
|
:command -nargs=0 WakaTimeDebugDisable call s:DisableDebugMode()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue