Skip to content

Commit 2c13833

Browse files
committed
Re-work install procedure
Instead of requiring users to install after doing a git pull we now create a .tgz release which can simply be unpacked. This .tgz file should contain all needed files to run the plugin. Add script to create a release bundle. Add script to create a portable pyls installation. Update README.rst Add DEVELOPMENT.rst to hide development information from the "normal" user.
1 parent fc16dd9 commit 2c13833

15 files changed

+330
-288
lines changed

.gitignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
*.pyc
22
__pycache__
33
plugin/log/*.log.*
4-
plugin/log/*.log
5-
plugin/vimlsp_servers
6-
plugin/supported_servers.json
4+
plugin/servers
75
plugin/tests/.lsp_install_dir
86
*.swp
97
*.cache

DEVELOPMENT.rst

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
vim-liq development
2+
===================
3+
4+
Todo
5+
----
6+
7+
#. Clean up, refactor
8+
#. Add documentation availible via help in vim
9+
#. Add support for more lsp servers
10+
#. Verify the plugin is working with vim built for python3 as well as 2
11+
#. Add rename support
12+
#. Automate release procedure
13+
#. Add travis support
14+
#. And much more
15+
16+
Development Requirements
17+
------------------------
18+
19+
* git
20+
* tox - for testing
21+
* python3 - for creating a release
22+
* pip - for installing python LSP server (pyls)
23+
24+
Testing (for developers)
25+
------------------------
26+
27+
Testing of the pythoncode is done with tox. So first make sure you have tox installed. E.g.::
28+
29+
pip install tox
30+
31+
Once tox is installed simply run tox from the plugin folder of vim-liq::
32+
33+
cd ~/path/to/vim-liq-repo/plugin
34+
tox
35+
36+
This will run unittests and linting (currently flake8 is used for linting). As a part of testing
37+
the lsp servers supported will be downloaded/installed locally in plugin/tests/.lsp_install_dir.
38+
This is however only done the first time the test is run. To force a re-install one must manually
39+
remove the .lsp_install_dir.
40+
41+
There currently is no tests for the vimscript code.

README.rst

+21-50
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ vim-liq
44
vim-liq is a vim client for the Language Server Protocol (LSP). vim-liq stands for something along
55
the lines of vim- "Language IQ" or "Lingustic Intelligence".
66

7-
Development Status
8-
------------------
9-
107
This project is in a beta state and may not be suitable for general use. But for those
118
willing to tinker a bit it might be worth a try :-).
129

10+
Features
11+
--------
12+
1313
The following high level, LSP, features have support:
1414

1515
#. Completion
@@ -18,42 +18,33 @@ The following high level, LSP, features have support:
1818
#. Definition
1919
#. Symbols
2020

21-
Todo
22-
----
23-
24-
#. Clean up, refactor
25-
#. Add documentation availible via help in vim
26-
#. Add support for more lsp servers
27-
#. Verify the plugin is working with vim built for python3 as well as 2
28-
#. Add rename support
29-
#. And much more
30-
3121
Installation
3222
------------
3323

3424
The instruction below is only tested on osX and Linux.
3525

36-
LSP client
37-
~~~~~~~~~~
26+
Installation is done by downloading an extracting a release bundle, e.g. using pathogen::
3827

39-
First one must download the plugin. This can be done by the normal means, e.g. by using pathogen:
28+
cd ~/.vim/bundle
29+
wget url_to_release.tgz
30+
tar xzf vim-liq.tgz
4031

41-
* [Pathogen](https://github.com/tpope/vim-pathogen)
42-
- `git clone https://github.com/kristopher-h/vim-liq ~/.vim/bundle/vim-liq`
32+
Note: Do not use git clone to clone the repo as that will leave you without any LSP servers. For
33+
more information see the DEVELOMPENT.rst.
4334

44-
LSP servers
45-
~~~~~~~~~~~
35+
Currently LSP servers for the following languages are included:
4636

47-
Once the plugin is installed one or more language servers must be installed. To install
48-
all supported language servers the following should do the trick::
37+
#. python
4938

50-
cd ~/.vim/bundle/vim-liq
51-
plugin/install_lsp_server.py
39+
Upgrading
40+
~~~~~~~~~
5241

53-
Currently only python language server is "supported", it is however possible to manually edit
54-
the supported_servers.json file to test with other language servers as well. The file does not
55-
exist until at least one lsp server has been installed. See plugin/supported_servers_example.json
56-
for an example of what the contents of the file should look like.
42+
To upgrade vim-liq simply remove the old vim-liq folder and redo the installation. Example::
43+
44+
cd ~/.vim/bundle
45+
rm -r vim-liq
46+
47+
After that redo the installation.
5748

5849
Usage
5950
-----
@@ -86,28 +77,7 @@ Requirements
8677
- quickfix
8778
- possibly more without me knowing it?
8879

89-
* python > 2.7 (running/installing python-language-server)
90-
* pytest, tox, mock for testing
91-
* pip (for installing python-language-server)
92-
93-
Testing (for developers)
94-
------------------------
95-
96-
Testing of the pythoncode is done with tox. So first make sure you have tox installed. E.g.::
97-
98-
pip install tox
99-
100-
Once tox is installed simply run tox from the plugin folder of vim-liq::
101-
102-
cd ~/.vim/bundle/vim-liq/plugin
103-
tox
104-
105-
This will run unittests and linting (currently flake8 is used for linting). As a part of testing
106-
the lsp servers supported will be downloaded/installed locally in plugin/tests/.lsp_install_dir.
107-
This is however only done the first time the test is run. To force a re-install one must manually
108-
remove the .lsp_install_dir.
109-
110-
There currently is no tests for the vimscript code.
80+
* python > 2.7 (for running the python language server)
11181

11282
Credits
11383
-------
@@ -120,6 +90,7 @@ this.
12090
* language-server-protocol (https://github.com/Microsoft/language-server-protocol/)
12191
* LanguageClient-neovim (https://github.com/autozimu/LanguageClient-neovim)
12292
* vim-plugin-starter-kit (https://github.com/JarrodCTaylor/vim-plugin-starter-kit)
93+
* Pathogen (https://github.com/tpope/vim-pathogen)
12394

12495
License
12596
-------

plugin/install_lsp_server.py

-80
This file was deleted.

plugin/log/README.rst

-5
This file was deleted.

plugin/servers.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"python": {
3+
"cmd": "python {{ PLUGIN_DIR }}/servers/python/pyls",
4+
"transport": "STDIO"
5+
}
6+
}

plugin/supported_servers_example.json

-7
This file was deleted.

plugin/vim_liq.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
import vimliq.clientmanager
2626
import vimliq.vimutils as V
2727

28-
server_file = os.path.join(os.path.dirname(__file__), "supported_servers.json")
28+
plugin_dir = os.path.dirname(__file__)
29+
server_file = os.path.join(plugin_dir, "servers.json")
2930

3031

3132
# Custom memory logger
@@ -56,6 +57,7 @@ def get_logs(self):
5657

5758

5859
LSP_LOG = MemHandler(1000)
60+
LSP = None
5961

6062

6163
# Setup logging
@@ -67,8 +69,12 @@ def get_logs(self):
6769

6870
if vim.eval("g:vim_lsp_log_to_file") == "1":
6971
pid = os.getpid()
72+
log_dir = vim.eval("g:vim_lsp_logdir")
73+
# Create dir if it does not exist
74+
if not os.path.exists(log_dir):
75+
os.makedirs(log_dir)
7076
handler = logging.handlers.RotatingFileHandler(
71-
os.path.join(vim.eval("g:vim_lsp_logdir"), "vim_lsp_{}.log".format(pid)),
77+
os.path.join(log_dir, "vim_lsp_{}.log".format(pid)),
7278
maxBytes=500000, backupCount=2)
7379
else:
7480
handler = LSP_LOG
@@ -82,9 +88,11 @@ def get_logs(self):
8288
with open(server_file, "r") as indata:
8389
try:
8490
supported_clients = json.load(indata)
91+
# Make relative paths absolute
92+
for _, client in supported_clients.items():
93+
client["cmd"] = client["cmd"].replace("{{ PLUGIN_DIR }}", plugin_dir)
94+
LSP = vimliq.clientmanager.ClientManager(supported_clients)
8595
except ValueError:
8696
log.error("Failed to load json file.")
8797
else:
8898
log.info("No supported clients file found. Forgot to install?")
89-
90-
LSP = vimliq.clientmanager.ClientManager(supported_clients)

plugin/vim_liq.vim

+30-11
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,39 @@ if exists("g:loaded_vim_lsp") || &cp
2222
finish
2323
endif
2424

25+
2526
" --------------------------------
2627
" Settings
2728
" --------------------------------
28-
let g:loaded_vim_lsp = 1
2929
let g:vim_lsp_logdir = expand("<sfile>:h")."/log/"
3030
let g:vim_lsp_log_to_file = 0
3131
let g:vim_lsp_debug = 1
32-
3332
sign define LspSign text=>>
3433

3534
" --------------------------------
3635
" Add our plugin to the path
3736
" --------------------------------
38-
python import os
39-
python import sys
40-
python import vim
41-
python sys.path.append(vim.eval('expand("<sfile>:h")'))
42-
python sys.path.append(os.path.join(vim.eval('expand("<sfile>:h")'), "vendor/lsp"))
43-
python from vim_liq import LSP
44-
python from vim_liq import LSP_LOG
37+
python << endOfPython
38+
import os
39+
import sys
40+
import vim
41+
sys.path.append(vim.eval('expand("<sfile>:h")'))
42+
sys.path.append(os.path.join(vim.eval('expand("<sfile>:h")'), "vendor/lsp"))
43+
from vim_liq import LSP
44+
lspLoaded = 0
45+
if LSP:
46+
lspLoaded = 1
47+
vim.command("let lspLoaded={}".format(lspLoaded))
48+
from vim_liq import LSP_LOG
49+
endOfPython
50+
51+
if lspLoaded == 0
52+
finish
53+
endif
54+
55+
" If we get here the plugin should have loaded correctly
56+
let g:loaded_vim_lsp = 1
57+
4558

4659
" --------------------------------
4760
" Function(s)
@@ -130,14 +143,20 @@ if LangSupport()
130143
python << endOfPython
131144
LSP.add_client()
132145
endOfPython
146+
endif
147+
148+
" TODO: Handle the support check better
149+
" check again if there is support since the add_client might have failed
150+
if LangSupport()
133151
setlocal completeopt=longest,menuone,preview
134-
setlocal omnifunc=LspOmniFunc
152+
setloca omnifunc=LspOmniFunc
135153

136154
call RegisterCommand()
137155
call RegisterAutoCmd()
138156
call RegisterKeyMap()
139157
call TdDidOpen()
140-
end
158+
endif
159+
141160
endfunction
142161

143162

plugin/vimliq/client.py

+1
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ def td_symbols(self):
243243
self._display_quickfix_from_location(symbols)
244244

245245
def td_completion(self):
246+
log.debug("PAPAPAP")
246247
if omni_findstart():
247248
return
248249
# Make sure server has latest info before trying to complete

0 commit comments

Comments
 (0)