nvchad/init.lua

74 lines
2.2 KiB
Lua

require "core"
vim.api.nvim_set_var('mapleader', ';')
local custom_init_path = vim.api.nvim_get_runtime_file("lua/custom/init.lua", false)[1]
if custom_init_path then
dofile(custom_init_path)
end
require("core.utils").load_mappings()
local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
-- bootstrap lazy.nvim!
if not vim.loop.fs_stat(lazypath) then
require("core.bootstrap").gen_chadrc_template()
require("core.bootstrap").lazy(lazypath)
end
dofile(vim.g.base46_cache .. "defaults")
vim.opt.rtp:prepend(lazypath)
require "plugins"
-- Configure Telescope to scroll files with ctrl+j/k
local actions = require('telescope.actions')
local sorters = require('telescope.sorters')
require('telescope').setup {
defaults = {
mappings = {
i = {
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
},
},
file_sorter = sorters.get_fzy_sorter,
file_ignore_patterns = { '.git/*', 'node_modules/*', 'vendor/*' },
generic_sorter = sorters.get_generic_fuzzy_sorter,
},
extensions = {
fzf = {
fuzzy = true,
override_generic_sorter = true,
override_file_sorter = true,
case_mode = "smart_case",
}
}
}
vim.api.nvim_set_keymap('n', '<leader>e', ':NvimTreeToggle<CR>', {noremap = true, silent = true})
-- Cycle through open buffers with leader+a
vim.api.nvim_set_keymap('n', '<leader>a', ':bprevious<CR>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<leader>f', ':bnext<CR>', {noremap = true, silent = true})
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
-- move the whole page without moving the cursor
vim.api.nvim_set_keymap('n', 'J', '<C-e>', { noremap = true })
vim.api.nvim_set_keymap('n', 'K', '<C-y>', { noremap = true })
-- Resize windows
vim.api.nvim_set_keymap('n', '<Up>', '5<C-w>+', { silent = true })
vim.api.nvim_set_keymap('n', '<Down>', '5<C-w>-', { silent = true })
vim.api.nvim_set_keymap('n', '<Right>', '10<C-w>>', { silent = true })
vim.api.nvim_set_keymap('n', '<Left>', '10<C-w><', { silent = true })
-- Set the tab width to 4 spaces
vim.cmd('set tabstop=4')
vim.cmd('set shiftwidth=4')
vim.cmd('set expandtab')