Skip to content

Commit

Permalink
Use methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Dec 9, 2023
1 parent 519c8a6 commit ea5c6f9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions autoload/ddc.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function ddc#enable(opts = {}) abort
if denops#plugin#is_loaded('ddc')
if 'ddc'->denops#plugin#is_loaded()
return
endif

Expand All @@ -24,7 +24,7 @@ function ddc#enable(opts = {}) abort
let g:ddc#_started = reltime()
let g:ddc#_context_filetype = context_filetype
let g:ddc#_skip_next_complete = 0
if !('g:ddc#_mods'->exists())
if !'g:ddc#_mods'->exists()
const g:ddc#_mods = [s:root_dir, 'denops', 'ddc', '_mods.js']->join(s:sep)
endif

Expand Down Expand Up @@ -82,7 +82,7 @@ endfunction
function ddc#on_complete_done(completed_item) abort
if !ddc#_denops_running()
\ || a:completed_item->empty()
\ || !(a:completed_item->has_key('user_data'))
\ || !a:completed_item->has_key('user_data')
\ || a:completed_item.user_data->type() != v:t_dict
return
endif
Expand Down Expand Up @@ -147,7 +147,7 @@ function ddc#skip_next_complete() abort
endif
endfunction

const s:root_dir = fnamemodify(expand('<sfile>'), ':h:h')
const s:root_dir = '<sfile>'->expand()->fnamemodify(':h:h')
const s:sep = has('win32') ? '\' : '/'
function ddc#_register() abort
call denops#plugin#register('ddc',
Expand Down
4 changes: 2 additions & 2 deletions autoload/ddc/map.vim
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ function ddc#map#manual_complete(options = {}) abort
endfunction

function ddc#map#can_complete() abort
return !(g:->get('ddc#_items', [])->empty())
return !g:->get('ddc#_items', [])->empty()
\ && g:->get('ddc#_complete_pos', -1) >= 0
endfunction

function ddc#map#extend(confirm_key) abort
if !('g:ddc#_sources'->exists())
if !'g:ddc#_sources'->exists()
return ''
endif
return a:confirm_key .. ddc#map#manual_complete(g:ddc#_sources)
Expand Down
12 changes: 6 additions & 6 deletions autoload/ddc/util.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function ddc#util#print_error(string, name = 'ddc') abort
echohl Error
echomsg printf('[%s] %s', a:name,
\ type(a:string) ==# v:t_string ? a:string : string(a:string))
\ type(a:string) ==# v:t_string ? a:string : a:string->string())
echohl None
endfunction

Expand All @@ -13,13 +13,13 @@ endfunction
function ddc#util#get_input(event) abort
const mode = a:event ==# 'InsertEnter' ? 'i' : mode()
const is_insert = (mode ==# 'i') || (mode ==# 't')
const text = ddc#util#get_text(mode)
const text = mode->ddc#util#get_text()
const col = mode() ==# 't' && !has('nvim') ?
\ term_getcursor(bufnr('%'))[1] :
\ term_getcursor('%'->bufnr())[1] :
\ mode() ==# 'c' ? getcmdpos() : col('.')
const pos = mode ==# 'c' ? col - 1 :
\ is_insert ? col - 1 : col
const input = pos >= len(text) ?
const input = pos >= text->len() ?
\ text :
\ text->matchstr(
\ '^.*\%' .. (is_insert || col <= 0 ? col : col - 1)
Expand All @@ -28,8 +28,8 @@ function ddc#util#get_input(event) abort
return input
endfunction
function ddc#util#get_next_input(event) abort
const text = ddc#util#get_text(mode())
return text[len(ddc#util#get_input(a:event)) :]
const text = mode()->ddc#util#get_text()
return text[a:event->ddc#util#get_input()->len() :]
endfunction

function ddc#util#benchmark(msg = '') abort
Expand Down

0 comments on commit ea5c6f9

Please sign in to comment.