CosmicNvim is a lightweight and opinionated Neovim config for web development, specifically designed to provide a π« COSMIC programming experience!
Full featured native LSP functionality!
- π Go-to definition
- π Find references/type def/declaration
- π‘ Code actions
- π¨ Statusline diagnostics
- π§ Formatting thanks to conform.nvim
- Custom rename and code action popups via Cosmic-UI
- Amazing default theme via tokyonight.nvim
- UI enhancements via snacks.nvim and noice.nvim
- Enhanced syntax highlighting via nvim-treesitter
- Custom statusline via lualine
- File editor via oil.nvim
- Floating terminal with toggleterm.nvim
- LSP server management via mason.nvim
- Autocompletion via blink.cmp
- Snippet support via LuaSnip
- Session management via auto-session
- Easy to find keybindings via which-key.nvim
- Floating windows for references, renaming, diagnostics, code actions and more!
While CosmicNvim is geared specifically toward TypeScript/JavaScript development, it should be able to provide a great experience with any LSP supported language.
- Neovim 0.13.0+ (Nightly)
- Git to clone CosmicNvim and install plugins
- Node.js with npm for JS/TS tooling
- External formatters for the languages you use, listed below
# Create and enter Neovim's config parent directory.
mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}" && cd "${XDG_CONFIG_HOME:-$HOME/.config}" || exit 1
# Move an existing config or symlink into a unique backup directory.
if [ -e nvim ] || [ -L nvim ]; then
backup_dir=$(mktemp -d "$PWD/nvim.backup.XXXXXX") || exit 1
mv nvim "$backup_dir/nvim" || exit 1
printf 'Previous config saved to %s/nvim\n' "$backup_dir"
fi
# Clone into the now-empty destination, then install plugins on first launch.
git clone https://github.com/CosmicNvim/CosmicNvim.git nvim && nvimBy default, this will assume the Cosmic git directory is placed at vim.fn.stdpath('config'), i.e. ~/.config/nvim.
If you are symlinking your pulled repo to ~/.config/nvim, you must define the shell environment variable
COSMICNVIM_INSTALL_DIR that points to your installation.
After plugins finish installing, run :checkhealth cosmic to check the installation and external tools.
Conform uses the following tools from lua/cosmic/plugins/conform/init.lua.
Install the tools for your filetypes and make sure Neovim can find their executables on PATH.
LSP server installation through Mason does not install all of these formatters.
| Filetypes | Configured formatters, in order |
|---|---|
| JavaScript, TypeScript, JSX, TSX | oxlint, oxfmt |
| CSS, SCSS, HTML, JSON, Markdown | oxfmt |
| Lua | stylua |
| Go | goimports, gofmt |
| Python | ruff_fix, ruff_format, ruff_organize_imports, all using the ruff executable |
For web tooling, install Node.js and npm, then run:
npm install -g oxlint oxfmtprettierd is not part of the default formatter configuration.
For other languages, install only what you need:
- Lua: install Rust/Cargo, then run
cargo install stylua --locked. Put~/.cargo/binonPATH. - Go: install Go, which includes
gofmt, then rungo install golang.org/x/tools/cmd/goimports@latest. Add$(go env GOPATH)/bintoPATH, or yourGOBINdirectory if you set one. - Python: install pipx, then run
pipx install ruffandpipx ensurepath.
Restart your shell and Neovim after changing PATH.
Open a source file and run :ConformInfo to see which formatters are available and inspect the formatter log.
Use :checkhealth cosmic for broader setup checks.
Additional CosmicNvim installation details.
Additional LSP server installation details.
CosmicNvim uninstallation details.
Plugin customization in lua/cosmic/config/config.lua uses:
plugins = { ... }for direct lazy.nvim specs{ 'repo/name', enabled = false }to disable a built-in plugin- another spec with the same repository ID to override a built-in plugin
lsp.servers.NAME = true | false | { ... }to enable, disable, or override an LSP server
Built-in LSP defaults come from nvim-lspconfig and are extended by after/lsp/*.lua. User config under
lsp.servers.NAME is merged on top of those defaults when the server is enabled.
Enabled servers are installed through Mason automatically.
Enabled servers are enabled by Cosmic with vim.lsp.enable().
disable_builtin_plugins, plugins.add, plugins.disable, plugins.opts, plugins.override, and lsp.servers.NAME.opts have been removed.
Pulls CosmicNvim updates with git pull --ff-only without blocking the editor.
Failures report Git's exit code and error output.
:CosmicUpdate
After a successful update, restart Neovim to load the changes.
