Neovim Setup and Config - blitterated/dotfiles GitHub Wiki
Neovim Setup and Config 1
brew install neovim
md -p ~/.config/nvim
Create config file and open for editing.
nvim ~/.config/nvim/init.lua
Configure Line Numbers in init.lua
-- Show line numbers by default
vim.cmd("set number")
Configure tabs/spaces. This uses double brackets, [[ ]]
, to enable multi-line vimscript in lua. 2
-- Configure Tabs
vim.cmd([[
set expandtab
set tabstop=2
set softtabstop=2
set shiftwidth=2
]])
Install lazy.nvim by adding it to to init.lua
3.
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
Before calling setup()
for Lazy, set up your leader keys by adding the following to init.lua
.
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
Reload Neovim config and test with the :Lazy
command 4.
Also run :checkhealth lazy
and see what it says 5.
Next, add the call to Lazy's setup()
in a way that the entire config can be modularized into separate files in a plugins directory tree of files 6.
require("lazy").setup("plugins")
Finally, create the root plugins
folder under the ~/.config/nvim
directory.
mkdir -p ~/.config/nvim/lua/plugins
Create and open catppuccin.lua
in nvim.
:e ~/.config/nvim/lua/plugins/catppuccin.lua
Add the following to catppuccin.lua
.
return {
"catppuccin/nvim",
lazy = false,
name = "catppuccin",
priority = 1000,
config = function()
vim.cmd.colorscheme "catppuccin"
end
}
Create and open everforest.lua
in nvim.
:e ~/.config/nvim/lua/plugins/everforest.lua
Add the following to everforest.lua
.
return {
"sainnhe/everforest",
lazy = false,
name = "everforest",
priority = 1000,
config = function()
vim.cmd.colorscheme "everforest"
end
Create and open sonokai.lua
in nvim.
:e ~/.config/nvim/lua/plugins/sonokai.lua
Add the following to sonokai.lua
.
return {
"sainnhe/sonokai",
lazy = false,
name = "sonokai",
priority = 1000,
config = function()
vim.cmd.colorscheme "sonokai"
end
Create and open vscode.lua
in nvim.
:e ~/.config/nvim/lua/plugins/vscode.lua
Add the following to vscode.lua
.
return {
"Mofiqul/vscode.nvim",
lazy = false,
name = "vscode",
priority = 1000,
config = function()
vim.cmd.colorscheme ""
end
Telescope 7
Telescope is a fuzzy finder and file grepper plugin.
Create and open telescope.lua
in nvim.
:e ~/.config/nvim/lua/plugins/telescope.lua
Add Telescope setup and some key mappings to telescope.lua
.
return {
'nvim-telescope/telescope.nvim',
tag = '0.1.8',
dependencies = { 'nvim-lua/plenary.nvim'},
config = function()
local builtin = require("telescope.builtin")
vim.keymap.set('n', '<C-p>', builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
end
}
Tree-sitter 8
Tree-sitter for Neovim is an AST parser used for functionality such as highlighting and indentation.
Create and open treesitter.lua
in nvim.
:e ~/.config/nvim/lua/plugins/treesitter.lua
Add Tree-sitter setup and some default parsers to treesitter.lua
return {
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
config = function()
local config = require("nvim-treesitter.configs")
config. setup ({
ensure_installed = {
"awk",
"bash",
"c_sharp",
"forth",
"html",
"java",
"javascript",
"json",
"lua",
"markdown",
"markdown_inline",
"python",
"ruby",
"sql",
"supercollider",
"tmux",
"vim"
},
highlight = { enable = true },
indent = { enable = true },
})
end
}
The :TSInstall
command can be used to install parsers on the fly.
Neo-tree 9
Create and open neotree.lua
in nvim.
:e ~/.config/nvim/lua/plugins/neotree.lua
Add Neo-tree setup and some default parsers to neotree.lua
return {
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim",
},
lazy = false, -- neo-tree will lazily load itself
config = function()
vim.keymap.set('n', '<C-n>', ':Neotree filesystem reveal left<CR>', {})
end
}
To add new files and directories, type a
while Neo-tree has focus.
First Mason LSP Install Results
Inst. | LSP | Error |
---|---|---|
❌ | awk-language-server | npm failed with exit code - and signal -. Could not find executable "npm" in PATH. |
❌ | bash-language-server | npm failed with exit code - and signal -. Could not find executable "npm" in PATH. |
✅ | marksman | |
❌ | sqls | go failed with exit code - and signal -. Could not find executable "go" in PATH. |
❌ | vim-language-server | npm failed with exit code - and signal -. Could not find executable "npm" in PATH. |
✅ | lua-language-server | |
✅ | python-lsp-server | |
❌ | ruby-lsp | gem failed with exit code 1 and signal 0. ERROR: Error installing ruby-lsp: sorbet-runtime requires Ruby version >= 2.7.0. The current ruby version is 2.6.10.210. ERROR: Error installing ruby-lsp-rails: sorbet-runtime requires Ruby version >= 2.7.0. The current ruby version is 2.6.10.210. |
Installed npm
with brew install npm
to fix awk_ls
, bashls
, and vimls
.
Installed go
with brew install go
to fix sqls
.
See Mason LSP Install Triage for details.
How to add footnotes to GitHub-flavoured Markdown?
- 👣 typecraft: Neovim for Newbs ↩
- 👣 Vim commands ↩
- 👣 typecraft: From 0 to IDE in NEOVIM from scratch - EP 1 - lazy.nvim install ↩
- 👣 typecraft: A BEAUTIFUL neovim config with Lazy - EP 2 - Modular Configs ↩
- 👣 Neovim Docs: checkhealth ↩
- 👣 typecraft: A BEAUTIFUL neovim config with Lazy - EP 2 - Modular Configs ↩
- 👣 typecraft: From 0 to IDE in NEOVIM from scratch - EP 1 - Telescope ↩
- 👣 typecraft: From 0 to IDE in NEOVIM from scratch - EP 1 - Tree-sitter ↩
- 👣 typecraft: A BEAUTIFUL neovim config with Lazy - EP 2 - Neo-tree ↩