Fix deoplete. Add more plugins.

master
blallo 4 years ago
parent 40eee4432a
commit 5b4ae3f7b9
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F
  1. 2
      bundle/ale
  2. 15
      bundle/deoplete-go/.dockerignore
  3. 29
      bundle/deoplete-go/.flake8
  4. 71
      bundle/deoplete-go/.gitignore
  5. 6
      bundle/deoplete-go/.gitmodules
  6. 37
      bundle/deoplete-go/.travis.yml
  7. 22
      bundle/deoplete-go/LICENSE
  8. 77
      bundle/deoplete-go/Makefile
  9. 377
      bundle/deoplete-go/README.md
  10. 22
      bundle/deoplete-go/benchmark/Dockerfile
  11. 77
      bundle/deoplete-go/benchmark/README.md
  12. 98
      bundle/deoplete-go/benchmark/benchmark.py
  13. 1
      bundle/deoplete-go/benchmark/json/fmt.json
  14. 1
      bundle/deoplete-go/benchmark/json/gocode-twice.json
  15. 1
      bundle/deoplete-go/benchmark/json/gocode.json
  16. 1
      bundle/deoplete-go/benchmark/json/syscall.json
  17. 4
      bundle/deoplete-go/benchmark/requirements.txt
  18. 86
      bundle/deoplete-go/data/gen_json.py
  19. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/archive/tar.json
  20. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/archive/zip.json
  21. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/bufio/bufio.json
  22. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/bytes/bytes.json
  23. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/compress/bzip2.json
  24. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/compress/flate.json
  25. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/compress/gzip.json
  26. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/compress/lzw.json
  27. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/compress/zlib.json
  28. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/container/heap.json
  29. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/container/list.json
  30. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/container/ring.json
  31. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/context/context.json
  32. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/aes.json
  33. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/cipher.json
  34. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/crypto.json
  35. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/des.json
  36. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/dsa.json
  37. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/ecdsa.json
  38. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/elliptic.json
  39. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/hmac.json
  40. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/md5.json
  41. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/rand.json
  42. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/rc4.json
  43. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/rsa.json
  44. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/sha1.json
  45. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/sha256.json
  46. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/sha512.json
  47. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/subtle.json
  48. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/tls.json
  49. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/x509.json
  50. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/crypto/x509/pkix.json
  51. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/database/sql.json
  52. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/database/sql/driver.json
  53. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/debug/dwarf.json
  54. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/debug/elf.json
  55. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/debug/gosym.json
  56. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/debug/macho.json
  57. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/debug/pe.json
  58. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/debug/plan9obj.json
  59. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/encoding/ascii85.json
  60. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/encoding/asn1.json
  61. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/encoding/base32.json
  62. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/encoding/base64.json
  63. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/encoding/binary.json
  64. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/encoding/csv.json
  65. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/encoding/encoding.json
  66. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/encoding/gob.json
  67. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/encoding/hex.json
  68. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/encoding/json.json
  69. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/encoding/pem.json
  70. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/encoding/xml.json
  71. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/errors/errors.json
  72. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/expvar/expvar.json
  73. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/flag/flag.json
  74. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/fmt/fmt.json
  75. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/go/ast.json
  76. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/go/build.json
  77. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/go/constant.json
  78. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/go/doc.json
  79. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/go/format.json
  80. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/go/importer.json
  81. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/go/parser.json
  82. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/go/printer.json
  83. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/go/scanner.json
  84. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/go/token.json
  85. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/go/types.json
  86. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/hash/adler32.json
  87. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/hash/crc32.json
  88. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/hash/crc64.json
  89. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/hash/fnv.json
  90. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/hash/hash.json
  91. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/html/html.json
  92. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/html/template.json
  93. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/image/color.json
  94. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/image/color/palette.json
  95. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/image/draw.json
  96. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/image/gif.json
  97. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/image/image.json
  98. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/image/jpeg.json
  99. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/image/png.json
  100. 1
      bundle/deoplete-go/data/json/1.7.3/darwin_amd64/index/suffixarray.json
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1 +1 @@
Subproject commit 79e42fed14b35767d53d7d443a644a037e012b89
Subproject commit bf17bbf898da6763e305a3e92f041532221719b0

@ -0,0 +1,15 @@
# directories
benchmark
build
images
plugin
data
# files
.DS_Store
*.tags
*.tar.gz
Dockerfile
!data/gen_json.py
!data/template.go

@ -0,0 +1,29 @@
# http://flake8.readthedocs.org/en/latest/config.html
[flake8]
# comma-separated filename and glob patterns
# default: .svn,CVS,.bzr,.hg,.git,__pycache
exclude = .svn,CVS,.bzr,.hg,.git,__pycache,tests/*
# comma-separatedd filename and glob patterns
# default: *.py
filename = *.py
# select errors and warnings tot enable which are off by default
# select =
# skip errers ror warnings.
# If the `ignore` option is blank, ignore the error codes are
# - E123/E133
# - E226
# - E241/E242
ignore = D100,D101,D102,D103,D104,D201D201,D202,D203,D204,E402,E123/E133,E226,E241/E242,H101,H301,H304,I100,I201
# set maximum allowed line length
# default: 79
max-line-length = 99
# set the error format
# format =
# McCable complexity threshold
max-complexity = 10

@ -0,0 +1,71 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# json tarballs
*.tar.gz
# deoplete-go original
# remote plugin specs
.-rplugin~
data/json/devel/**
data/stdlib-devel_darwin_amd64.txt

@ -0,0 +1,6 @@
[submodule "rplugin/python3/deoplete/ujson"]
path = rplugin/python3/deoplete/ujson
url = https://github.com/esnme/ultrajson.git
[submodule "rplugin/python3/deoplete/clang"]
path = rplugin/python3/deoplete/clang
url = https://github.com/zchee/libclang-python3

File diff suppressed because one or more lines are too long

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2016 Koichi Shiraishi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

@ -0,0 +1,77 @@
CURRENT := $(shell pwd)
RPLUGIN_HOME := $(CURRENT)/rplugin/python3
RPLUGIN_PATH := $(RPLUGIN_HOME)/deoplete/sources
MODULE_NAME := deoplete_go.py deoplete_go/cgo.py deoplete_go/stdlib.py
TARGET = $(RPLUGIN_HOME)/deoplete/ujson.so
GOCODE := $(shell which gocode)
GO_VERSION = $(shell go version | awk '{print $$3}' | sed -e 's/go//')
GO_STABLE_VERSION = 1.10.1
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
GIT := $(shell which git)
PYTHON3 := $(shell which python3)
DOCKER := $(shell which docker)
DOCKER_IMAGE := zchee/deoplete-go:${GO_STABLE_VERSION}-linux_amd64
PACKAGE ?= unsafe
ifneq ($(PACKAGE),unsafe)
PACKAGE += unsafe
endif
PIP_FLAGS ?=
all: $(TARGET)
rplugin/python3/deoplete/ujson/.git:
$(GIT) submodule update --init
$(TARGET): rplugin/python3/deoplete/ujson/.git
cd ./rplugin/python3/deoplete/ujson; $(PYTHON3) setup.py build --build-base="$(CURRENT)/build" --build-lib="$(CURRENT)/build"
mv "$(CURRENT)/build/ujson."*".so" "$(TARGET)"
data/stdlib-$(GO_VERSION)_$(GOOS)_$(GOARCH).txt:
go tool api -contexts $(GOOS)-$(GOARCH)-cgo | sed -e s/,//g | awk '{print $$2}' | uniq > ./data/stdlib-$(GO_VERSION)_$(GOOS)_$(GOARCH).txt
@for pkg in $(PACKAGE) ; do \
echo $$pkg >> ./data/stdlib-$(GO_VERSION)_$(GOOS)_$(GOARCH).txt; \
done
gen_json: data/stdlib-$(GO_VERSION)_$(GOOS)_$(GOARCH).txt
$(GOCODE) close
$(GOCODE) set package-lookup-mode go
cd ./data && ./gen_json.py $(GOOS) $(GOARCH)
docker/build:
$(DOCKER) build -t $(DOCKER_IMAGE) .
docker/gen_stdlib: docker/build
$(DOCKER) run --rm $(DOCKER_IMAGE) cat /deoplete-go/data/stdlib-${GO_STABLE_VERSION}_linux_amd64.txt > ./data/stdlib-${GO_STABLE_VERSION}_linux_amd64.txt
docker/gen_json: docker/gen_stdlib
$(DOCKER) run --rm $(DOCKER_IMAGE) > ./json_${GO_STABLE_VERSION}_linux_amd64.tar.gz
tar xf ./json_${GO_STABLE_VERSION}_linux_amd64.tar.gz
mv ./json_${GO_STABLE_VERSION}_linux_amd64.tar.gz ./data/json_${GO_STABLE_VERSION}_linux_amd64.tar.gz
test: lint
lint: lint/flake8
lint/flake8:
flake8 --config=$(PWD)/.flake8 $(foreach file,$(MODULE_NAME),$(RPLUGIN_PATH)/$(file)) || true
lint/install_modules:
pip3 install -U $(PIP_FLAGS) -r ./tests/requirements.txt
clean:
$(RM) -r "$(CURRENT)/build" "$(TARGET)" rplugin/python3/deoplete/ujson/build data/stdlib-$(GO_VERSION)_$(GOOS)_$(GOARCH).txt
.PHONY: test lint clean gen_json build

@ -0,0 +1,377 @@
# deoplete-go
|| **Status** |
|:---:|:---:|
| **Travis CI** |[![Build Status](https://travis-ci.org/zchee/deoplete-go.svg?branch=master)](https://travis-ci.org/zchee/deoplete-go)|
| **Gitter** |[![Join the chat at https://gitter.im/zchee/deoplete-go](https://badges.gitter.im/zchee/deoplete-go.svg)](https://gitter.im/zchee/deoplete-go?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)|
Go source for [deoplete.nvim](https://github.com/Shougo/deoplete.nvim) use [gocode](https://github.com/stamblerre/gocode).
## Overview
Asynchronous Go completion for Neovim/Vim8.
Use,
### deoplete.nvim
[Shougo/deoplete.nvim](https://github.com/Shougo/deoplete.nvim)
Dark powered asynchronous completion framework for neovim/Vim8.
Fastetst, Fully asynchronous, Nonblocking user interface, Customizable source
for each languages, and more. The Nextgen word completion.
### gocode
[stamblerre/gocode](https://github.com/stamblerre/gocode)
An autocompletion daemon for the Go programming language.
Fastest, Context-sensitive, Server/Client architecture, Result caching.
The *de facto* standard completion engine.
Note: Another gocode is avaiable.
It seems faster?
https://github.com/visualfc/gocode
---
## Required
### deoplete.nvim
https://github.com/Shougo/deoplete.nvim
### gocode
https://github.com/stamblerre/gocode
---
## How to install
### 1. Install Neovim or Vim8
For neovim, see Neovim wiki.
- [Installing Neovim](https://github.com/neovim/neovim/wiki/Installing-Neovim)
- [Following HEAD](https://github.com/neovim/neovim/wiki/Following-HEAD)
- [Building](https://github.com/neovim/neovim/wiki/Building-Neovim)
### 2. Install deoplete
See https://github.com/Shougo/deoplete.nvim
### 3. Install latest of gocode
```bash
go get -u github.com/stamblerre/gocode
```
### 4. Install plugin and Build ujson module
`deoplete-go` using [esnme/ultrajson](https://github.com/esnme/ultrajson) json module.
It's Python bindings for C library. Need compiling.
So, If you use Plugin manager supported build process, set `make` commmand.
```vim
" dein.vim
call dein#add('Shougo/deoplete.nvim')
call dein#add('deoplete-plugins/deoplete-go', {'build': 'make'})
" NeoBundle
NeoBundle 'Shougo/deoplete.nvim'
NeoBundle 'deoplete-plugins/deoplete-go', {'build': {'unix': 'make'}}
" vim-plug
Plug 'Shougo/deoplete.nvim'
Plug 'deoplete-plugins/deoplete-go', { 'do': 'make'}
```
---
## Available Settings
| Setting value | Default | Required |
|:---------------------------------------: |:-------:|:-------------:|
| `g:deoplete#sources#go#gocode_binary` | `''` | **Recommend** |
| `g:deoplete#sources#go#package_dot` | `0` | No |
| `g:deoplete#sources#go#sort_class` | `[]` | **Recommend** |
| `g:deoplete#sources#go#cgo` | `0` | *Any* |
| `g:deoplete#sources#go#goos` | `''` | No |
| `g:deoplete#sources#go#source_importer` | `0` | No |
| `g:deoplete#sources#go#builtin_objects` | `0` | No |
| `g:deoplete#sources#go#unimported_packages` | `0` | No |
| `g:deoplete#sources#go#fallback_to_source ` | `0` | No |
### `g:deoplete#sources#go#gocode_binary`
#### `gocode` Binary
| **Default** | `''` |
|--------------|-------------------------|
| **Required** | **Recommend** |
| **Type** | string |
| **Example** | `$GOPATH.'/bin/gocode'` |
`deoplete-go` will directly call `gocode`. Not vim bypass due to the omnifunc.
By default (not set), Find the gocode binary in `$PATH` environment.
This setting is **Recommend**.
If you set it, `deoplete-go` spared look for the binary. It will improve performance.
Also, If you want to use a different from the first found `gocode` binary from `$PATH` then set:
```vim
let g:deoplete#sources#go#gocode_binary = '/path/to/gocode'
```
### `g:deoplete#sources#go#package_dot`
#### Automatically insert dot after package name
| **Default** | `0` |
|--------------|-----|
| **Required** | No |
| **Type** | int |
| **Example** | `1` |
Automatically insert dot (period) when you select `package` name in popup menu.
By default, no dot (period) is inserted after a package name.
If you would prefer adding a period then set:
```vim
let g:deoplete#sources#go#package_dot = 1
```
### `g:deoplete#sources#go#sort_class`
#### Class Sorting and Ignore
| **Default** | `[]` |
|--------------|--------------------|
| **Required** | **Recommend** |
| **Type** | list |
| **Example** | See bellow exmaple |
By default, the completion word list is in the sort order of gocode. Same as
omnifunc. If you want to change it to an arbitrary order, set it.
Available values are [`package`, `func`, `type`, `var`, `const`].
If you did not include any value, it will always be hidden in the completion
list.
To display all words while sorting, set:
```vim
let g:deoplete#sources#go#sort_class = ['package', 'func', 'type', 'var', 'const']
```
### `g:deoplete#sources#go#pointer`
#### Support pointer match
| **Default** | `0` |
|--------------|-------|
| **Required** | *Any* |
| **Type** | int |
| **Example** | `1` |
Support pointer (`*`) match.
Example are bellow code. `|` is cursor.
```go
type Foo struct {
FooName string
}
func NewFoo() *Foo {
return &Foo{}
}
func (f *|
```
### `g:deoplete#sources#go#cgo`
#### cgo complete use libclang-python3
| **Default** | `0` |
|--------------|-------|
| **Required** | *Any* |
| **Type** | int |
| **Example** | `1` |
If current buffer has `import "C"` also `#include <foo.h>` and when you type
`C.`, deoplete-go will display the C function in the `foo.h`.
Simple example is below. `|` is cursor.
```go
package main
/*
#include <stdlib.h>
*/
import "C"
import (
"fmt"
)
func main() {
fmt.Printf()
C.|
}
```
Will return the `pid_t`, `malloc`, `free` and more.
The real example uses libgit2.
```go
package main
/*
#include <git2.h>
*/
import "C"
import (
"log"
"os"
"path/filepath"
"github.com/libgit2/git2go"
)
func main() {
repoPath := filepath.Join(os.Getenv("GOPATH"), "src/github.com/libgit2/git2go")
gitRepo, err := git.OpenRepository(repoPath)
C.git_blame_|
if err != nil {
log.Fatal(err)
}
commitOid, err := gitRepo.Head()
if err != nil {
}
}
```
Will return that completion list.
![cgo_libgit2](images/cgo_libgit2.png)
Now support current buffer only.
TODO: Support parses `.c`, `.h` file.
### `g:deoplete#sources#go#cgo#libclang_path`
#### libclang shared library path for cgo complete
| **Default** | ` ` |
|--------------|--------------------------------|
| **Required** | *Any* |
| **Type** | string |
| **Example** | `/opt/llvm/lib/libclang.dylib` |
libclang shared library path option.
In darwin, `libclang.dylib`, In Linux, `libclang.so`.
### `g:deoplete#sources#go#cgo#std`
#### C language standard version
| **Default** | `c11` |
|--------------|--------|
| **Required** | *Any* |
| **Type** | string |
| **Example** | `c99` |
C language standard version option.
If not set, deoplete-go uses `c11`(latest) version.
### `g:deoplete#sources#go#auto_goos`
#### Automatically set GOOS environment variable when calling `gocode`
| **Default** | `0` |
|--------------|---------|
| **Required** | No |
| **Type** | boolean |
| **Example** | `1` |
When enabled, deoplete-go will try to set `GOOS` by checking the file name for
`name_<OS>.go`. If not found, the file will be checked for a `// +build <OS>`
directive. If the file's OS doesn't match your OS (e.g. `file_darwin.go`
while on `linux`), `CGO_ENABLED=0` will also be set.
**Note:** There may be a 5-10 second delay if `gocode` needs to compile the
platform-specific sources for the first time.
### `g:deoplete#sources#go#source_importer`
#### Enable source importer
| **Default** | `0` |
|--------------|-----|
| **Required** | No |
| **Type** | int |
| **Example** | `1` |
When enabled, deoplete-go can complete external packages.
It is deprecated option. You should use the latest gocode.
https://github.com/mdempsky/gocode/pull/71
### `g:deoplete#sources#go#builtin_objects`
#### Propose builtin objects
| **Default** | `0` |
|--------------|-----|
| **Required** | No |
| **Type** | int |
| **Example** | `1` |
When enabled, deoplete-go can complete builtin objects.
### `g:deoplete#sources#go#unimported_packages`
#### Propose completions for unimported standard library packages
| **Default** | `0` |
|--------------|-----|
| **Required** | No |
| **Type** | int |
| **Example** | `1` |
When enabled, deoplete-go can complete standard library packages that are
not explicitely imported yet.
### `g:deoplete#sources#go#fallback_to_source`
#### Scan source files when a dependency is not found on the GOPATH
| **Default** | `0` |
|--------------|-----|
| **Required** | No |
| **Type** | int |
| **Example** | `1` |
When enabled, deoplete-go will try the source importer when it fails
to find a dependency on the GOPATH.
---
## Sample init.vim
```vim
" neocomplete like
set completeopt+=noinsert
" deoplete.nvim recommend
set completeopt+=noselect
" Path to python interpreter for neovim
let g:python3_host_prog = '/path/to/python3'
" Skip the check of neovim module
let g:python3_host_skip_check = 1
" Run deoplete.nvim automatically
let g:deoplete#enable_at_startup = 1
" deoplete-go settings
let g:deoplete#sources#go#gocode_binary = $GOPATH.'/bin/gocode'
let g:deoplete#sources#go#sort_class = ['package', 'func', 'type', 'var', 'const']
```
---
TODO:
-----
- [x] Parse included cgo (C, C++ language) headers on current buffer
- `ctags` will be blocking `deoplete.nvim`
- [x] Support static json caching
- See https://github.com/deoplete-plugins/deoplete-go/pull/19
- [x] Support Go stdlib package `import "***"` name completion
- This feature has been implemented in gocode. Thanks @nhooyr!
- [x] Execute `gocode` binary instead of call vim function
- [x] Get and parse completion list of json format. such as `ycm`
- [x] When there is no candidate infomation, deoplete will cause an error
- [x] Support fizzy matching

@ -0,0 +1,22 @@
FROM ubuntu:xenial
MAINTAINER zchee <k@zchee.io>
COPY ./requirements.txt /python_jsonbench/requirements.txt
RUN set -ex \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
gcc \
g++ \
git \
python3-dev \
python3-pip \
&& rm -rf /var/lib/apt/lists/* \
\
&& pip3 install -U pip setuptools \
&& pip3 install -r /python_jsonbench/requirements.txt
COPY . /python_jsonbench
WORKDIR /python_jsonbench
CMD ["python3", "benchmark.py"]

@ -0,0 +1,77 @@
```bash
> python3 benchmark.py
Running json benchmarks...
Running simplejson benchmarks...
Running ujson benchmarks...
Running rapidjson benchmarks...
Results
=======
# filesize: 2248 byte
loads (fmt.json)
--------------------
json 0.00288 s
simplejson 0.00257 s
ujson 0.00327 s
rapidjson 0.00504 s
# filesize: 116347 byte
loads (syscall.json)
--------------------
json 0.16875 s
simplejson 0.15083 s
ujson 0.12698 s
rapidjson 0.15828 s
# filesize: 160808 byte
loads (gocode.json)
--------------------
json 0.22175 s
simplejson 0.18736 s
ujson 0.17142 s
rapidjson 0.20404 s
# filesize: 1768818 byte
loads (gocode-twice.json)
--------------------
json 2.94173 s
simplejson 2.60381 s
ujson 2.63998 s
rapidjson 3.08415 s
# filesize: 2248 byte
dumps (fmt.json)
--------------------
json 0.00347 s
simplejson 0.00430 s
ujson 0.00178 s
rapidjson 0.00305 s
# filesize: 116347 byte
dumps (syscall.json)
--------------------
json 0.21460 s
simplejson 0.25808 s
ujson 0.08036 s
rapidjson 0.06591 s
# filesize: 160808 byte
dumps (gocode.json)
--------------------
json 0.29153 s
simplejson 0.35043 s
ujson 0.14064 s
rapidjson 0.08929 s
# filesize: 1768818 byte
dumps (gocode-twice.json)
--------------------
json 3.56336 s
simplejson 3.97017 s
ujson 1.37770 s
rapidjson 1.09713 s
python3 benchmark.py 21.92s user 2.28s system 99% cpu 24.324 total
```

@ -0,0 +1,98 @@
from __future__ import print_function
import timeit
import importlib
import json
from collections import defaultdict
NUMBER = 100
def benchmark_loads(module, data):
module.loads(data)
def benchmark_dumps(module, obj):
module.dumps(obj)
def benchmark_loads_byline(module, lines):
for line in lines:
module.loads(line)
def benchmark_dumps_byline(module, lines):
for obj in lines:
module.dumps(obj)
def import_modules():
for name in ['json', 'simplejson', 'ujson', 'rapidjson']:
try:
yield importlib.import_module(name)
except ImportError:
print('Unable to import {}'.format(name))
continue
def print_results(results):
for suite_name, suite_results in results.items():
print(suite_name)
print('-' * 20)
for module_name, result in sorted(suite_results.items(), key=lambda x:x[1]):
print('{:10} {:.5f} s'.format(module_name, result))
print()
def run_benchmarks():
# filesize: 2248 byte
with open('json/fmt.json') as f:
fmt_objs_data = f.readlines()
fmt_objs = [json.loads(line) for line in fmt_objs_data]
# filesize: 116347 byte
with open('json/syscall.json') as f:
syscall_objs_data = f.readlines()
syscall_objs = [json.loads(line) for line in syscall_objs_data]
# filesize: 160808 byte
with open('json/gocode.json') as f:
gocode_objs_data = f.readlines()
gocode_objs = [json.loads(line) for line in gocode_objs_data]
# filesize: 1768818 byte
with open('json/gocode-twice.json') as f:
gocode_twice_objs_data = f.readlines()
gocode_twice_objs = [json.loads(line) for line in gocode_twice_objs_data]
results = defaultdict(dict)
modules = import_modules()
for module in modules:
module_name = module.__name__
print('Running {} benchmarks...'.format(module_name))
results['loads (fmt.json)'][module_name] = timeit.timeit(
lambda: benchmark_loads_byline(module, fmt_objs_data), number=NUMBER)
results['dumps (fmt.json)'][module_name] = timeit.timeit(
lambda: benchmark_dumps_byline(module, fmt_objs), number=NUMBER)
results['loads (syscall.json)'][module_name] = timeit.timeit(
lambda: benchmark_loads_byline(module, syscall_objs_data), number=NUMBER)
results['dumps (syscall.json)'][module_name] = timeit.timeit(
lambda: benchmark_dumps_byline(module, syscall_objs), number=NUMBER)
results['loads (gocode.json)'][module_name] = timeit.timeit(
lambda: benchmark_loads_byline(module, gocode_objs_data), number=NUMBER)
results['dumps (gocode.json)'][module_name] = timeit.timeit(
lambda: benchmark_dumps_byline(module, gocode_objs), number=NUMBER)
results['loads (gocode-twice.json)'][module_name] = timeit.timeit(
lambda: benchmark_loads_byline(module, gocode_twice_objs_data), number=NUMBER)
results['dumps (gocode-twice.json)'][module_name] = timeit.timeit(
lambda: benchmark_dumps_byline(module, gocode_twice_objs), number=NUMBER)
print('\nResults\n=======')
print_results(results)
if __name__ == '__main__':
run_benchmarks()

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1,4 @@
git+https://github.com/simplejson/simplejson
git+https://github.com/esnme/ultrajson
# git+https://github.com/hhatto/pyrapidjson
git+https://github.com/kenrobbins/python-rapidjson

@ -0,0 +1,86 @@
#!/usr/bin/env python3
import json
import os
import subprocess
import sys
import re
def main():
base_offset = 41
go_version_raw = subprocess.Popen("go version",
shell=True,
stdout=subprocess.PIPE
).stdout.read()
go_version = str(go_version_raw).split(' ')[2].strip('go')
go_os = sys.argv[1]
go_arch = sys.argv[2]
with open('./stdlib-' + go_version + '_' + go_os + '_' + go_arch + '.txt') as stdlib:
packages = stdlib.read().splitlines()
for pkg in packages:
template_file = './template.go'
f = open(template_file)
fs = f.read(-1)
func = None
if re.search(r'/', pkg):
library = str(pkg).split(r'/')[:-1]
func = str(pkg).split(r'/')[-1]
else:
library = pkg
func = pkg
source = str(fs).replace('IMPORT', pkg).replace('FUNC', func).encode()
offset = base_offset + (len(pkg) + len(func))
process = subprocess.Popen([FindBinaryPath('gocode'),
'-f=json',
'autocomplete',
template_file,
str(offset)],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
start_new_session=True)
process.stdin.write(source)
stdout_data, stderr_data = process.communicate()
result = json.loads(stdout_data.decode())
out_dir = os.path.join(
'./json', go_version, go_os + '_' + go_arch)
if not os.path.exists(out_dir):
os.makedirs(out_dir)
libdir = str(pkg).rsplit('/', 1)[0]
pkg_dir = os.path.join(out_dir, libdir)
if not os.path.exists(pkg_dir):
os.makedirs(pkg_dir)
out_path = \
os.path.join(pkg_dir, func + '.json')
out = open(out_path, 'w')
out.write(json.dumps(result, sort_keys=True))
out.close()
print(pkg)
def FindBinaryPath(cmd):
def is_exec(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(cmd)
if fpath:
if is_exec(cmd):
return cmd
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
binary = os.path.join(path, cmd)
if is_exec(binary):
return binary
return print('gocode binary not found')
main()

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
[0, [{"class": "func", "name": "NewReader", "type": "func(r io.Reader) io.Reader"}, {"class": "type", "name": "StructuralError", "type": "string"}]]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
[0, [{"class": "const", "name": "LSB", "type": ""}, {"class": "const", "name": "MSB", "type": ""}, {"class": "func", "name": "NewReader", "type": "func(r io.Reader, order lzw.Order, litWidth int) io.ReadCloser"}, {"class": "func", "name": "NewWriter", "type": "func(w io.Writer, order lzw.Order, litWidth int) io.WriteCloser"}, {"class": "type", "name": "Order", "type": "int"}]]

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
[0, [{"class": "func", "name": "Fix", "type": "func(h heap.Interface, i int)"}, {"class": "func", "name": "Init", "type": "func(h heap.Interface)"}, {"class": "func", "name": "Pop", "type": "func(h heap.Interface) interface{}"}, {"class": "func", "name": "Push", "type": "func(h heap.Interface, x interface{})"}, {"class": "func", "name": "Remove", "type": "func(h heap.Interface, i int) interface{}"}, {"class": "type", "name": "Interface", "type": "interface"}]]

@ -0,0 +1 @@
[0, [{"class": "func", "name": "New", "type": "func() *list.List"}, {"class": "type", "name": "Element", "type": "struct"}, {"class": "type", "name": "List", "type": "struct"}]]

@ -0,0 +1 @@
[0, [{"class": "func", "name": "New", "type": "func(n int) *ring.Ring"}, {"class": "type", "name": "Ring", "type": "struct"}]]

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
[0, [{"class": "const", "name": "BlockSize", "type": ""}, {"class": "func", "name": "NewCipher", "type": "func(key []byte) (cipher.Block, error)"}, {"class": "type", "name": "KeySizeError", "type": "int"}]]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
[0, [{"class": "const", "name": "BlockSize", "type": ""}, {"class": "func", "name": "NewCipher", "type": "func(key []byte) (cipher.Block, error)"}, {"class": "func", "name": "NewTripleDESCipher", "type": "func(key []byte) (cipher.Block, error)"}, {"class": "type", "name": "KeySizeError", "type": "int"}]]

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
[0, [{"class": "func", "name": "GenerateKey", "type": "func(c elliptic.Curve, rand io.Reader) (*ecdsa.PrivateKey, error)"}, {"class": "func", "name": "Sign", "type": "func(rand io.Reader, priv *ecdsa.PrivateKey, hash []byte) (r *big.Int, s *big.Int, err error)"}, {"class": "func", "name": "Verify", "type": "func(pub *ecdsa.PublicKey, hash []byte, r *big.Int, s *big.Int) bool"}, {"class": "type", "name": "PrivateKey", "type": "struct"}, {"class": "type", "name": "PublicKey", "type": "struct"}]]

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
[0, [{"class": "func", "name": "Equal", "type": "func(mac1 []byte, mac2 []byte) bool"}, {"class": "func", "name": "New", "type": "func(h func() hash.Hash, key []byte) hash.Hash"}]]

@ -0,0 +1 @@
[0, [{"class": "const", "name": "BlockSize", "type": ""}, {"class": "const", "name": "Size", "type": ""}, {"class": "func", "name": "New", "type": "func() hash.Hash"}, {"class": "func", "name": "Sum", "type": "func(data []byte) [16]byte"}]]

@ -0,0 +1 @@
[0, [{"class": "func", "name": "Int", "type": "func(rand io.Reader, max *big.Int) (n *big.Int, err error)"}, {"class": "func", "name": "Prime", "type": "func(rand io.Reader, bits int) (p *big.Int, err error)"}, {"class": "func", "name": "Read", "type": "func(b []byte) (n int, err error)"}, {"class": "var", "name": "Reader", "type": "io.Reader"}]]

@ -0,0 +1 @@
[0, [{"class": "func", "name": "NewCipher", "type": "func(key []byte) (*rc4.Cipher, error)"}, {"class": "type", "name": "Cipher", "type": "struct"}, {"class": "type", "name": "KeySizeError", "type": "int"}]]

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
[0, [{"class": "const", "name": "BlockSize", "type": ""}, {"class": "const", "name": "Size", "type": ""}, {"class": "func", "name": "New", "type": "func() hash.Hash"}, {"class": "func", "name": "Sum", "type": "func(data []byte) [20]byte"}]]

@ -0,0 +1 @@
[0, [{"class": "const", "name": "BlockSize", "type": ""}, {"class": "const", "name": "Size", "type": ""}, {"class": "const", "name": "Size224", "type": ""}, {"class": "func", "name": "New", "type": "func() hash.Hash"}, {"class": "func", "name": "New224", "type": "func() hash.Hash"}, {"class": "func", "name": "Sum224", "type": "func(data []byte) (sum224 [28]byte)"}, {"class": "func", "name": "Sum256", "type": "func(data []byte) [32]byte"}]]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
[0, [{"class": "type", "name": "BinaryMarshaler", "type": "interface"}, {"class": "type", "name": "BinaryUnmarshaler", "type": "interface"}, {"class": "type", "name": "TextMarshaler", "type": "interface"}, {"class": "type", "name": "TextUnmarshaler", "type": "interface"}]]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
[0, [{"class": "func", "name": "Decode", "type": "func(data []byte) (p *pem.Block, rest []byte)"}, {"class": "func", "name": "Encode", "type": "func(out io.Writer, b *pem.Block) error"}, {"class": "func", "name": "EncodeToMemory", "type": "func(b *pem.Block) []byte"}, {"class": "type", "name": "Block", "type": "struct"}]]

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
[0, [{"class": "func", "name": "New", "type": "func(text string) error"}]]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
[0, [{"class": "func", "name": "Node", "type": "func(dst io.Writer, fset *token.FileSet, node interface{}) error"}, {"class": "func", "name": "Source", "type": "func(src []byte) ([]byte, error)"}]]

@ -0,0 +1 @@
[0, [{"class": "func", "name": "Default", "type": "func() types.Importer"}, {"class": "func", "name": "For", "type": "func(compiler string, lookup importer.Lookup) types.Importer"}, {"class": "type", "name": "Lookup", "type": "func(path string) (io.ReadCloser, error)"}]]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
[0, [{"class": "const", "name": "ScanComments", "type": ""}, {"class": "func", "name": "PrintError", "type": "func(w io.Writer, err error)"}, {"class": "type", "name": "Error", "type": "struct"}, {"class": "type", "name": "ErrorHandler", "type": "func(pos token.Position, msg string)"}, {"class": "type", "name": "ErrorList", "type": "[]*scanner.Error"}, {"class": "type", "name": "Mode", "type": "uint"}, {"class": "type", "name": "Scanner", "type": "struct"}]]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
[0, [{"class": "const", "name": "Size", "type": ""}, {"class": "func", "name": "Checksum", "type": "func(data []byte) uint32"}, {"class": "func", "name": "New", "type": "func() hash.Hash32"}]]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
[0, [{"class": "func", "name": "New32", "type": "func() hash.Hash32"}, {"class": "func", "name": "New32a", "type": "func() hash.Hash32"}, {"class": "func", "name": "New64", "type": "func() hash.Hash64"}, {"class": "func", "name": "New64a", "type": "func() hash.Hash64"}]]

@ -0,0 +1 @@
[0, [{"class": "type", "name": "Hash", "type": "interface"}, {"class": "type", "name": "Hash32", "type": "interface"}, {"class": "type", "name": "Hash64", "type": "interface"}]]

@ -0,0 +1 @@
[0, [{"class": "func", "name": "EscapeString", "type": "func(s string) string"}, {"class": "func", "name": "UnescapeString", "type": "func(s string) string"}]]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
[0, [{"class": "var", "name": "Plan9", "type": "[]color.Color"}, {"class": "var", "name": "WebSafe", "type": "[]color.Color"}]]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
[0, [{"class": "func", "name": "New", "type": "func(data []byte) *suffixarray.Index"}, {"class": "type", "name": "Index", "type": "struct"}]]

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save