Skip to content

Commit

Permalink
fix: Ensure we can install treesitter parsers from cli
Browse files Browse the repository at this point in the history
  • Loading branch information
flovilmart committed Nov 5, 2024
1 parent d9ff24a commit 0a3ccb1
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
plugged
plugged/
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ COPY . .

# Adds SSH keys to make sure we can clone submodules
RUN --mount=type=ssh ./install.sh all
RUN sed -i "s#/opt/homebrew/bin/nu#/bin/bash#" ./plugin/after/styling.lua


CMD nu

Check warning on line 15 in Dockerfile

View workflow job for this annotation

GitHub Actions / Docker build

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
39 changes: 32 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ all() {
install_apk_deps
mkdir -p ${HOME}/.config
ln -sfn $(pwd) ${HOME}/.config/nvim
nvim -c PlugInstall -c "write ${TMPDIR}/PlugInstall.out" -c quitall
cat ${TMPDIR}/PlugInstall.out
nvim -c PlugStatus -c "write ${TMPDIR}/PlugStatus.out" -c quitall
cat ${TMPDIR}/PlugStatus.out
fix_shell_path

# sleep 20s, no way I know to wait until everything is installed
nvim -c "TSUpdate" -c "60sleep" -c quitall
install_nvim_deps
setup_treesitter

lang_server ruby
lang_server typescript
Expand All @@ -31,8 +28,19 @@ install_apk_deps() {
fi
}

install_nvim_deps() {
nvim -c PlugInstall -c "write ${TMPDIR}/PlugInstall.out" -c quitall
cat ${TMPDIR}/PlugInstall.out
nvim -c PlugStatus -c "write ${TMPDIR}/PlugStatus.out" -c quitall
cat ${TMPDIR}/PlugStatus.out
}

setup_treesitter() {
nvim +TSUpdateSync +quitall
}

setup_shell() {
if command -v brew > /dev/null; then
if command -v nu > /dev/null; then
NUSHELL_PATH=$(which nu)
if [ "${NUSHELL_PATH}" != "/usr/bin/nu" ]; then
echo "Setting up NuShell to /usr/bin/nu"
Expand All @@ -41,6 +49,23 @@ setup_shell() {
fi
}

fix_shell_path() {
SHELL_PATH=""
if command -v nu > /dev/null; then
SHELL_PATH=$(which nu)
fi

if [ -z "${SHELL_PATH}" ]; then
SHELL_PATH="/bin/bash"
echo "Nu not found in path. Using /bin/bash as default"
fi
if [ "${SHELL_PATH}" == "/opt/homebrew/bin/nu" ]; then
echo "nothing to do..."
else
sed -i "s#/opt/homebrew/bin/nu#${SHELL_PATH}#" ./plugin/after/styling.lua
fi
}

lang_server() {
java() {
which brew && brew install jdtls
Expand Down
2 changes: 1 addition & 1 deletion lua/flovilmart/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ vim.call('plug#begin', '~/.config/nvim/plugged')
Plug ('vim-airline/vim-airline-themes')

--" TreeSitter: Code parsing
Plug ('nvim-treesitter/nvim-treesitter', { ['do'] = vim.fn['TSUpdate'] })
Plug ('nvim-treesitter/nvim-treesitter')
Plug ('nvim-treesitter/playground')

--" Git
Expand Down
4 changes: 2 additions & 2 deletions plugin/after/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ require'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all" (the five listed parsers should always be installed)
ensure_installed = { "ruby", "typescript", "javascript", "go", "lua", "vim", "query", "vimdoc", "c", "rust" },

sync_install = false,
auto_install = true,
sync_install = true,
auto_install = false,

highlight = {
enable = true,
Expand Down

0 comments on commit 0a3ccb1

Please sign in to comment.