Skip to content

Commit 749069b

Browse files
committed
Add Bash Lang Server & preview window opts for YouCompleteMe (Vim)
1 parent 58e3c1e commit 749069b

File tree

4 files changed

+46
-9
lines changed

4 files changed

+46
-9
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
lsp-examples/
2+
.*.swp
3+

.vimrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,8 @@ let g:clang_format#detect_style_file = 1
121121
let g:clang_format#auto_filetypes = ["c", "cpp"]
122122
let g:clang_format#auto_format = 1
123123

124+
" 'YouCompleteMe' plugin options
125+
" https://github.com/ycm-core/YouCompleteMe
126+
let g:ycm_autoclose_preview_window_after_insertion = 1
127+
let g:ycm_autoclose_preview_window_after_completion = 1
128+

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ arguments with which the script is invoked.
3939

4040
#### `--install-pkg`
4141

42-
- Install packages on supported OSs. Symlinking (setup) will be done after
43-
package installation.
42+
- Install packages and plugin-extras on supported OSs. Symlinking (setup) will
43+
be done after package installation.
4444
- Requirement: Optional, but note that some Vim plugins depend on packages to
4545
be installed to work.
4646
- Packages installed

setup

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -o pipefail -E -e -u
55
readonly FALSE=0
66
readonly TRUE=1
77

8+
dotfiles_repo_path="$(dirname "$(realpath "$0")")"
89
is_force_setup=${FALSE}
910
is_install_pkg=${FALSE}
1011

@@ -32,8 +33,8 @@ OPTIONS
3233
Requirement: Optional
3334
3435
--install-pkg
35-
Install packages on supported OSs. Symlinking (setup) will be done
36-
after package installation.
36+
Install packages and plugin-extras on supported OSs. Symlinking (setup)
37+
will be done after package installation.
3738
Requirement: Optional, but note that some Vim plugins depend on packages
3839
to be installed to work.
3940
Installed packages: bear, build-essential, clang-format, cmake, curl, git,
@@ -56,6 +57,34 @@ REPORTING BUGS
5657
"
5758
}
5859

60+
# Install Bash Language Server for YouCompleteMe Vim plugin
61+
add_youcompleteme_extra_support() {
62+
lsp_dir="${dotfiles_repo_path}/lsp-examples"
63+
vimrc_path="${dotfiles_repo_path}/.vimrc"
64+
curr_vimrc_last_line="$(tail --lines=1 "${vimrc_path}")"
65+
vimrc_line_to_add="source ${lsp_dir}/vimrc.generated"
66+
67+
if [[ -d "${lsp_dir}" ]]; then
68+
rm -rf "${lsp_dir}"
69+
fi
70+
71+
if [[ "${curr_vimrc_last_line}" == "${vimrc_line_to_add}" ]]; then
72+
head --lines=-1 "${vimrc_path}" > "${dotfiles_repo_path}/temp.vimrc" \
73+
&& mv "${dotfiles_repo_path}/temp.vimrc" "${vimrc_path}"
74+
fi
75+
76+
git clone https://github.com/ycm-core/lsp-examples.git "${lsp_dir}"
77+
78+
curr_dir="$(pwd)"
79+
cd "${lsp_dir}" && ./install.py "--enable-bash"
80+
cd "${curr_dir}"
81+
82+
echo "${vimrc_line_to_add}" >> "${dotfiles_repo_path}/.vimrc"
83+
84+
echo ""
85+
echo "Above line added to .vimrc!"
86+
}
87+
5988
# Handle command-line arguments
6089
if [[ "$#" -gt 0 ]]; then
6190
while [[ "$#" -gt 0 ]]; do
@@ -82,10 +111,7 @@ if [[ "$#" -gt 0 ]]; then
82111
done
83112
fi
84113

85-
# Set dotfiles repository directory path
86-
dotfiles_repo_path="$(dirname "$(realpath "$0")")"
87-
88-
# Install packages
114+
# Install packages and plugin-extras
89115
if [[ "${is_install_pkg}" == "${TRUE}" ]]; then
90116
if command -v "apt-get"; then
91117
echo ""
@@ -97,8 +123,10 @@ if [[ "${is_install_pkg}" == "${TRUE}" ]]; then
97123
git man net-tools nodejs npm python3 python3-dev shellcheck shfmt \
98124
tmux vim
99125

126+
add_youcompleteme_extra_support
127+
100128
echo ""
101-
echo "Package installation complete!"
129+
echo "Package and plugin-extras installation complete!"
102130
echo ""
103131
else
104132
echo ""
@@ -118,6 +146,7 @@ file_list=$(ls -A "${dotfiles_repo_path}")
118146
for file_name in ${file_list}; do
119147
if [[ ("${file_name:0:1}" != ".") ||
120148
("${file_name}" == ".git") ||
149+
("${file_name}" == ".gitignore") ||
121150
("${file_name}" == *".swp") ]]; then
122151
continue
123152
fi

0 commit comments

Comments
 (0)