Comments (10)
@cvlmtg Thanks a lot for the PR.
Closing this issue, for the any related file asyncompletions we can now use https://github.com/prabirshrestha/asyncomplete-file.vim to continue discussion there.
from asyncomplete.vim.
This is on my todo list. For now you can use vim file completion using <c-x><c-f>
with asyncomplete.
from asyncomplete.vim.
created an empty repository for now https://github.com/prabirshrestha/asyncomplete-file.vim
from asyncomplete.vim.
I just noticed vim's path
option recently, it's usefule to integrate it into the completion too.
NCM currently uses these base directories for path completion:
- directory of current buffer
expand('%:p')
- directory of current working directory
getcwd()
- root directory, which is
/
on linux system. - directories listed in
path
option
from asyncomplete.vim.
Given that we now have LSP support for both vim and neovim with autocomplete that works for asyncomplete, NCM and deoplete might be better to write a lang server instead. This way one could write in any language they want and actually be used by in any plugin. Here is a language server I wrote for typescript https://github.com/prabirshrestha/typescript-language-server. It is very easy to write one.
from asyncomplete.vim.
Hi, i've hacked together a file completion source. I'm a total vimscript noob, so this code is probably inefficient or event totally wrong (and it's not async), but it seems to do its work, so I'm sharing it here with the hope it might be useful to someone else, until a proper plugin is written by someone more experienced 😃
the path is always relative to the file being edited and there are no configurations or other tricks (like maybe using git ls-files
in a git repo) but this is left as an exercise to the reader
function! s:filename_map(prefix, file) abort
let l:abbr = fnamemodify(a:file, ':t')
let l:word = a:prefix . l:abbr
return {
\ 'menu': '[path]',
\ 'word': l:word,
\ 'abbr': l:abbr,
\ 'icase': 1,
\ 'dup': 0
\ }
endfunction
function! s:filename_completor(opt, ctx) abort
let l:bufnr = a:ctx['bufnr']
let l:typed = a:ctx['typed']
let l:col = a:ctx['col']
let l:kw = matchstr(l:typed, '<\@<!\.\{0,2}/.*$')
let l:kwlen = len(l:kw)
if l:kwlen < 1
return
endif
if l:kw !~ '^/'
let l:cwd = expand('#' . l:bufnr . ':p:h') . '/' . l:kw
else
let l:cwd = l:kw
endif
let l:glob = fnamemodify(l:cwd, ':t') . '*'
let l:cwd = fnamemodify(l:cwd, ':p:h')
let l:pre = fnamemodify(l:kw, ':h')
if l:pre !~ '/$'
let l:pre = l:pre . '/'
endif
let l:cwdlen = strlen(l:cwd)
let l:startcol = l:col - l:kwlen
let l:files = split(globpath(l:cwd, l:glob), '\n')
let l:matches = map(l:files, {key, val -> s:filename_map(l:pre, val)})
call asyncomplete#complete(a:opt['name'], a:ctx, l:startcol, l:matches)
endfunction
call asyncomplete#register_source({
\ 'name': 'filenam',
\ 'whitelist': ['*'],
\ 'priority': 10,
\ 'completor': function('s:filename_completor'),
\ })
from asyncomplete.vim.
@cvlmtg could you send a PR to https://github.com/prabirshrestha/asyncomplete-file.vim?
from asyncomplete.vim.
@prabirshrestha if you think this code is good enough I will
from asyncomplete.vim.
(btw the fork button is disabled. maybe you should push a commit first)
and... since I've never written a vim plugin before, a minimal empty template would help me a lot!
from asyncomplete.vim.
@cvlmtg send a PR and we can iterate there. Easier to comment in a PR. I pushed the initial commit you should be able to fork now.
from asyncomplete.vim.
Related Issues (20)
- Completion of buffer/workspace content HOT 3
- Auto-select the first candidate in the popup HOT 4
- Unable to list all the matching candidates if struct having a lot of methods for Go HOT 1
- Enter a new line ONLY when nothing is selected?
- Popup doesn't show for eclipse-jdt-ls HOT 6
- Avoid crlf line endings HOT 13
- [help] Is it possible to limit completion to one level instead of searching recursively? HOT 1
- [Question] How to auto popup struct field or class memer in C/C++ when you type dot or -> HOT 4
- Vim9Script HOT 1
- Add smart-case sensitive completion HOT 1
- How to disable arguments hinting window ? HOT 1
- [feature-request] Use a customizable popup window instead of vim native completion popup ? HOT 1
- Completion menu is opening/closing rapidly HOT 1
- asyncomplete should popup only snippets
- Dependency Dashboard HOT 1
- Strange behaviour with vim-lsp+clangd+asyncomplete-lsp HOT 1
- different complete behavier when open a file directly and enter nvim then use `e` command. HOT 1
- asyncomplete lags during gdscript completion (godot lsp) HOT 2
- Omni-completion is causing some issue with autocomplete, and doesn't work most of the time HOT 1
- nextword auto complete not working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asyncomplete.vim.