Last active
November 13, 2024 16:21
-
-
Save zgfif/d283e3a9b6ded9346a95e7d4364ed035 to your computer and use it in GitHub Desktop.
How to configure Neovim for Windows 11 by using init.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Create file init.lua in C:\Users\your_name\AppData\Local\nvim\init.lua | |
2. Add to file init.lua parameters for tabs (for Python I use 4 spaces for identation): | |
vim.cmd("set expandtab") | |
vim.cmd("set tabstop=4") | |
vim.cmd("set softtabstop=4") | |
vim.cmd("set shiftwidth=4") | |
3. Add to init.lua configuration for lazy.nvim package manager | |
https://lazy.folke.io/installation | |
https://github.com/folke/lazy.nvim?tab=readme-ov-file | |
4. Set color scheme: | |
https://github.com/catppuccin/nvim | |
5. Install lua (required for lazy.nvim): | |
https://github.com/LazerLars/how_to_setup_lua_in_windows11_and_vscode | |
6. Install, symilarly, luarocks | |
https://github.com/luarocks/luarocks/wiki/Installation-instructions-for-Windows | |
7. Add configuration for Telescope: | |
https://github.com/nvim-telescope/telescope.nvim | |
8. Add configuration for nvim-treesitter | |
https://github.com/nvim-treesitter/nvim-treesitter/wiki/Installation | |
9. Install C compiler for "nvim-treesitter" I'v installed "Mingw toolchain" | |
https://github.com/nvim-treesitter/nvim-treesitter/wiki/Windows-support | |
10. Install neo-tree and add shortcut Ctrl-n to open filetree | |
https://github.com/nvim-neo-tree/neo-tree.nvim | |
-- shortcut for neo-tree | |
vim.keymap.set('n', '<C-n>', ':Neotree filesystem reveal left<CR>', { desc = '' }) -- opening filetree Ctrl + n | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vim.cmd("set expandtab") | |
vim.cmd("set tabstop=4") | |
vim.cmd("set softtabstop=4") | |
vim.cmd("set shiftwidth=4") | |
vim.g.mapleader = " " --sets <leader> key as a space | |
-- 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) | |
-- 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 = "\\" | |
-- Setup lazy.nvim | |
require("lazy").setup({ | |
spec = { | |
{ "catppuccin/nvim", name = "catppuccin", priority = 1000 }, | |
{ | |
'nvim-telescope/telescope.nvim', tag = '0.1.8', --fuzzy search | |
dependencies = { 'nvim-lua/plenary.nvim' } | |
}, | |
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" }, | |
{ | |
"nvim-neo-tree/neo-tree.nvim", | |
branch = "v3.x", | |
dependencies = { | |
"nvim-lua/plenary.nvim", | |
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended | |
"MunifTanjim/nui.nvim", | |
-- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information | |
} | |
} | |
-- add your plugins here | |
}, | |
-- Configure any other settings here. See the documentation for more details. | |
-- colorscheme that will be used when installing plugins. | |
install = { colorscheme = { "habamax" } }, | |
-- automatically check for plugin updates | |
checker = { enabled = true }, | |
}) | |
require 'nvim-treesitter.install'.prefer_git = false | |
-- configurations for treesitter: | |
local configs = require("nvim-treesitter.configs") | |
configs.setup({ | |
ensure_installed = {"lua", "javascript", "python", "html"}, | |
highlight = { enable = true }, | |
indent = { enable = true }, | |
}) | |
-- shortcuts for Telescope | |
local builtin = require('telescope.builtin') | |
vim.keymap.set('n', '<C-p>', builtin.find_files, { desc = 'Telescope find files' }) -- set shortcut Ctrl + p | |
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope live grep' }) -- call command live_grep after writting '<leader>fg' | |
-- shortcut for neo-tree | |
vim.keymap.set('n', '<C-n>', ':Neotree filesystem reveal left<CR>', { desc = '' }) -- opening filetree Ctrl + n | |
-- set colorscheme | |
require("catppuccin").setup() | |
vim.cmd.colorscheme "catppuccin" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment