You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
dotfiles/nvim/init.lua

87 lines
2.4 KiB

-- some basic options
local vim = vim
local fn = vim.fn
vim.g.mapleader = "\\"
vim.g.maplocalleader = "\\"
vim.g.noswapfile = true
vim.g.python3_host_prog = fn.exepath("python3")
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.softtabstop = 2
vim.opt.expandtab = true
vim.opt.termguicolors = true
vim.opt.autoindent = true
vim.opt.smartindent = true
vim.opt.smarttab = true
vim.opt.number = true
vim.opt.hlsearch = false
vim.opt.wrap = true
vim.opt.linebreak = true
vim.opt.showmatch = true
vim.opt.completeopt = { 'menu', 'menuone', 'noselect', 'noinsert' }
vim.opt.shortmess = vim.opt.shortmess + "c"
vim.opt.autochdir = true
vim.opt.spelllang = 'en_us'
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
vim.o.foldenable = false
vim.o.laststatus = 3
vim.o.cmdheight = 0 -- hides commandbar when not in use, looks ok
vim.o.hidden = true
vim.o.signcolumn = 'auto'
-- vim.o.breakindent = false -- I think this looks bad
vim.o.errorbells = true
vim.o.clipboard = "unnamedplus"
vim.o.mouse = 'a'
vim.o.mousemoveevent = true
vim.wo.cursorline = true
vim.api.nvim_create_user_command('W', 'write', {})
function map(mode, shortcut, command)
vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true })
end
-- normal mode map
function nmap(shortcut, command)
map('n', shortcut, command)
end
-- insert mode map
function imap(shortcut, command)
map('i', shortcut, command)
end
nmap("<leader>ec", ':edit ' .. vim.fn.stdpath('config') .. '/init.lua<CR>')
-- toggle terminal in both modes
nmap("<leader>t", "<cmd>FloatermToggle<cr>")
map("t", "<leader>t", "<cmd>FloatermToggle<cr>")
nmap("<leader>dd", "<cmd>lua vim.diagnostic.open_float() <CR>")
-- 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)
require("lazy").setup({
spec = {
{ import = "plugins" }
},
checker = { enabled = true }
})