Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ghazanhaider/d2afe1bfb94810742979d9d19df7bd78 to your computer and use it in GitHub Desktop.

Select an option

Save ghazanhaider/d2afe1bfb94810742979d9d19df7bd78 to your computer and use it in GitHub Desktop.
Neovim config
Configuring neovim
On macos we install neovim and tree-sitter through homebrew
The 'Lazy' plugin autofetches colorschemes and treesitter (maybe ignoring the above) using git
To check the status:
:TSConfigInfo
:Lazy
I keep everything in init.lua rather than adding lazy.lua etc and other config files
I use init.lua instead of init.vim
This setup is really fast on a macbook. Additional tree-sitter options are to be tested against speed
######################### Install
brew install neovim
brew install tree-sitter
brew install tree-sitter-cli
brew install font-meslo-lg-nerd-font
...
alias vi=/opt/homebrew/opt/neovim/bin/nvim
######################### Contents of ~/.config/nvim/init.lua
-- [[ Basic Settings ]]
-- Set <space> as the leader key
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- Line numbers
vim.opt.number = true
vim.opt.relativenumber = false -- Shows relative line numbers
-- Search behavior
vim.opt.ignorecase = true -- Ignore case when searching
vim.opt.smartcase = true -- Don't ignore case if search has capitals
-- Indentation
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
-- Appearance
vim.opt.termguicolors = true -- Enable 24-bit RGB colors
vim.opt.cursorline = true -- Highlight the current line
-- [[ Keymaps ]]
-- Map 'jj' to <Esc> in insert mode for faster exiting
vim.keymap.set('i', 'jj', '<Esc>')
-- Clear search highlights on pressing <Esc> in normal mode
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- [[ Plugin Management ]]
-- Bootstrap lazy.nvim (automatically installs it if missing)
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git", "clone", "--filter=blob:none",
"https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{ "catppuccin/nvim", name = "catppuccin", priority = 1000 }, -- A popular theme
{ "folke/tokyonight.nvim", name = "tokyonight", lazy = false, priority = 1000 }, -- A popular theme
{
-- Highlight, edit, and navigate code
'nvim-treesitter/nvim-treesitter',
branch = 'master', -- <--- ADD THIS LINE
build = ':TSUpdate',
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
opts = {
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'python' },
-- Autoinstall languages that are not installed
auto_install = true,
highlight = {
enable = true,
-- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
-- If you are experiencing weird indenting issues, add the language to
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
additional_vim_regex_highlighting = { 'ruby' },
},
indent = { enable = true, disable = { 'ruby' } },
},
-- There are additional nvim-treesitter modules that you can use to interact
-- with nvim-treesitter. You should go explore a few and see what interests you:
--
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
},
})
vim.cmd([[colorscheme tokyonight]])
##################################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment