Skip to content
Β 
Β 

Latest commit

Β 

History

110 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AstroNvim Termux Setup πŸš€

A pre-configured, mobile-optimized AstroNvim v6+ configuration tailored specifically for Termux (Android) and Linux environments.

This setup uses native binary detection to bypass Mason glibc compatibility issues on Android, providing high-performance LSP servers, Treesitter parsers, None-LS formatters, and Live PDF Preview for LaTeX and Markdown files.


πŸ“‹ Table of Contents


πŸ›  Supported Languages & Tools

Language / Filetype Language Server (LSP) Formatter / Linter Binary Source
Lua lua_ls stylua Termux pkg
Bash / Shell bashls shfmt npm / Termux pkg
C / C++ / ObjC clangd / ccls clang-format Termux pkg
Rust rust_analyzer cargo fmt Termux pkg / Cargo
LaTeX / TeX texlab / digestif LSP / latexindent Termux pkg / LuaRocks
Markdown / Web render-markdown prettier Termux pkg / npm / Lazy Spec
JSON / JQ jq_lsp prettier Termux pkg / npm
Fish Shell fish_lsp fish_indent npm / Termux pkg
Smali (Android Bytecode) smali_lsp LSP Diagnostics Built fat JAR (smali-lsp-1.5.0.jar)

βš™οΈ System Requirements

  • Termux on Android (ARM64 aarch64 or 32-bit armv7l).
  • Neovim 0.10+ (AstroNvim v6+ compatible).
  • C/C++ build toolchain (clang, build-essential, make).
  • Rust toolchain (cargo, rustc).
  • typst & pandoc for PDF compilation and live preview.

πŸ“₯ Step-by-Step Installation Guide

Step 1: Install Termux System Packages

Run the following command in Termux to install Neovim, compilers, development tools, PDF generators, and native LSP packages:

apt update && yes | apt upgrade
apt install -y \
  git \
  neovim \
  build-essential \
  clang \
  ccls \
  ripgrep \
  fzf \
  rust \
  rust-analyzer \
  lua-language-server \
  luarocks \
  nodejs-lts \
  python \
  jq \
  fish \
  shfmt \
  stylua \
  tree-sitter \
  texinfo \
  texlab \
  tectonic \
  typst \
  pandoc

Note on fish_indent & Fish Shell:
fish_indent comes pre-packaged with fish. Installing pkg install fish automatically places fish_indent at /data/data/com.termux/files/usr/bin/fish_indent. none-ls automatically detects it for formatting .fish files.

Step 2: Install Global npm & LuaRocks Packages

Install Node.js based LSPs/formatters, fish-lsp, and the Lua-based TeX LSP (digestif):

# Install bash language server, prettier, and fish-lsp globally via npm
npm install -g bash-language-server prettier @fish-lsp/fish-lsp

# Install digestif (LaTeX LSP) via LuaRocks
luarocks install digestif

Step 3: Optional Android NDK Native Stubs

If you are compiling C/C++ or Rust libraries that link directly against Android NDK native shared libraries (like liblog, libandroid, libvulkan), install NDK native stubs:

pkg install ndk-multilib ndk-multilib-native-stubs

Step 4: Update Shell PATH

Ensure your shell (~/.bashrc, ~/.zshrc, or config.fish) includes ~/.cargo/bin and ~/.local/bin in your environment PATH.

Add the following to ~/.bashrc:

export PATH="$HOME/.cargo/bin:$HOME/.local/bin:$HOME/bin:$PATH"

Apply changes immediately:

source ~/.bashrc

Step 5: Backup Existing Neovim Configuration

If you have an existing Neovim configuration, back it up first:

mv ~/.config/nvim ~/.config/nvim.bak
mv ~/.local/share/nvim ~/.local/share/nvim.bak
mv ~/.local/state/nvim ~/.local/state/nvim.bak
mv ~/.cache/nvim ~/.cache/nvim.bak

Step 6: Clone Repository

Clone this repository into ~/.config/nvim:

git clone https://github.com/remo7777/Astronvim-Termux ~/.config/nvim

Step 7: Launch Neovim

Start Neovim for the first time. Plugins will automatically download and sync via lazy.nvim:

nvim

πŸ“„ LaTeX & Markdown Live PDF Preview

This setup includes a complete document editing suite with TeXLab LSP, VimTeX, and Knap Live PDF Preview supporting both LaTeX (.tex) and Markdown (.md) files.

Preview Features

  1. Typst Engine: Uses typst as the PDF rendering engine for ultra-fast, high-quality compilation with full UTF-8 Unicode and Emoji support (πŸ“˜, πŸ’‘, πŸ‹οΈ).
  2. TeXLab LSP Tuning: Suppresses harmless "Unused label" diagnostic hints while retaining error diagnostics.
  3. VimTeX Integration: AstroCommunity VimTeX integration (astrocommunity.markdown-and-latex.vimtex) for LaTeX syntax highlighting, TOC navigation (:VimtexTocOpen), and environment motions.
  4. Android Native Viewer: Uses termux-open to automatically open and refresh generated PDF files in your default Android PDF Viewer / Reader.

WhichKey Keymaps (Buffer-Local)

The <Leader>k group is buffer-local and appears in WhichKey when editing LaTeX (.tex, .plaintex) or Markdown (.md) files. On other files (.sh, .lua, .py, .c), <Leader>k remains hidden.

When editing a .tex or .md file, press <Space> (Leader key) to see:

k - 󰈦 Preview
β”œβ”€β”€ p - Toggle Live PDF Preview
β”œβ”€β”€ v - Jump to PDF Viewer
└── c - Close PDF Viewer
  • <Leader>kp : Toggle Live Auto-Preview ON/OFF (Compiles on save and opens PDF via termux-open)
  • <Leader>kv : Refresh / Jump to PDF Viewer
  • <Leader>kc : Close PDF Viewer

Termux LD_PRELOAD Environment Fix

In Termux, Neovim exports LD_PRELOAD=/data/data/com.termux/files/usr/lib/libluajit.so. When Pandoc (which uses standard Lua 5.4) is spawned from inside Neovim (jobstart), force-preloaded LuaJIT symbols cause dynamic symbol conflicts resulting in PANIC: unprotected error in call to Lua API (exit code 1).

This configuration automatically prepends env LD_PRELOAD= to all Knap execution routines (knap.lua), ensuring clean, error-free PDF background rendering:

textopdf = "env LD_PRELOAD= pandoc %docroot% -o %outputfile% --pdf-engine=typst",
mdtopdf = "env LD_PRELOAD= pandoc %docroot% -o %outputfile% --pdf-engine=typst",

πŸ€– Smali (Android Bytecode) LSP Environment

This setup includes a native Smali Language Server (smali_lsp) and Tree-sitter Smali environment for Android bytecode reverse engineering.

Smali Features

  1. Smali LSP (smali_lsp): Real-time syntax and semantic diagnostics (textDocument/publishDiagnostics), class/method document symbols, declaration lookups, and autocompletion.
  2. Global Binary Launcher: Executable launcher at ~/.local/bin/smali-lsp running the high-performance Kotlin/ANTLR shadow JAR (smali-lsp-1.5.0.jar).
  3. Automatic Workspace Detection: Automatically attaches to project roots containing .git, AndroidManifest.xml, or apktool.yml, with single-file fallback.
  4. Tree-sitter Smali: Fast syntax highlighting and AST node parsing via nvim-treesitter.

⚑ Building blink.cmp Natively (libblink_cmp_fuzzy.so)

blink.cmp uses a C/Rust dynamic shared library (libblink_cmp_fuzzy.so) for ultra-fast fuzzy completion matching. Precompiled glibc binaries fail on Android/Termux, so it must be built natively using Cargo.

Requirements

  • Rust Compiler & Toolchain: pkg install rust build-essential git

Manual Build Steps

# 1. Navigate to the blink.cmp plugin directory in Lazy:
cd ~/.local/share/nvim/lazy/blink.cmp

# 2. Build the shared library using Cargo:
cargo build --release

# 3. Verify the generated shared library:
ls -lh target/release/libblink_cmp_fuzzy.so

Lazy.nvim Automatic Build Specification

In your Neovim plugin setup, force lazy.nvim to build the Rust library natively on update:

{
  "Saghen/blink.cmp",
  build = "cargo build --release",
  opts = {
    -- Your blink.cmp configuration options
  },
}

πŸ“± 32-Bit Termux (ARMv7 / armhf / i686) Guide

If you are running Termux on a 32-bit Android device (armv7l or i686), precompiled 64-bit binaries from Mason or GitHub releases will fail. Follow these solutions:

1. Ensure Mason is Disabled

In lua/plugins/astrolsp.lua, ensure mason = false remains set. This forces AstroLSP to look for system binaries installed via pkg, luarocks, cargo, and npm.

2. Install Native 32-bit Packages

Always use Termux's native package manager to fetch 32-bit compiled binaries:

pkg update && pkg upgrade -y
pkg install -y git neovim build-essential clang rust luarocks nodejs-lts python tree-sitter typst pandoc

3. Enable TUR (Termux User Repository) for Missing Packages

If a specific LSP package is missing in 32-bit main repos, install tur-repo:

pkg install tur-repo
pkg update

4. Compiling blink.cmp or Cargo Crates on 32-Bit

Running cargo build --release inside plugin folders automatically detects 32-bit architecture (armv7-linux-androideabi) and compiles compatible .so dynamic libraries natively on your device.

5. Treesitter Parser Compilation

Ensure clang and build-essential are installed so nvim-treesitter can compile 32-bit parser binaries (.so) on the fly when opening files for the first time.


πŸ” Verification & Diagnostics

Inside Neovim, verify that all plugins and LSPs are installed properly:

:checkhealth
:LspInfo

To test loaded AstroLSP server status from the command line:

nvim --headless +":lua print(vim.inspect(require('astrolsp').config.servers))" +q

About

AstroNvim template (v6+)

Resources

Stars

25 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages