127 lines
6.4 KiB
Lua
127 lines
6.4 KiB
Lua
----- Plugins -------------------------------------------------------------
|
|
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 = {
|
|
{
|
|
"folke/todo-comments.nvim",
|
|
dependencies = { "nvim-lua/plenary.nvim" },
|
|
opts = { signs = false }
|
|
},
|
|
{
|
|
'numToStr/Comment.nvim',
|
|
opts = { }
|
|
},
|
|
{
|
|
'lewis6991/gitsigns.nvim',
|
|
},
|
|
{
|
|
'nvim-telescope/telescope.nvim', version = '*',
|
|
dependencies = {
|
|
'nvim-lua/plenary.nvim',
|
|
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' },
|
|
}
|
|
},
|
|
{
|
|
'Vonr/align.nvim',
|
|
branch = "v2",
|
|
lazy = true,
|
|
init = function()
|
|
-- mappings here...
|
|
end
|
|
},
|
|
{
|
|
"L3MON4D3/LuaSnip",
|
|
version = "v2.5",
|
|
},
|
|
},
|
|
|
|
install = { colorscheme = { "habamax" } },
|
|
checker = { enabled = false }, -- automatic updates
|
|
})
|
|
|
|
----- Settings ------------------------------------------------------------
|
|
vim.cmd("filetype plugin indent on")
|
|
vim.cmd("colorscheme habamax") -- or wildchart
|
|
vim.opt.backup = false
|
|
vim.opt.writebackup = false
|
|
vim.opt.swapfile = false
|
|
vim.opt.number = true
|
|
vim.opt.tabstop = 8
|
|
vim.opt.shiftwidth = 4
|
|
vim.opt.softtabstop = 4
|
|
vim.opt.expandtab = true
|
|
vim.opt.autoindent = true
|
|
vim.opt.smarttab = true
|
|
vim.opt.mouse = "a"
|
|
vim.opt.laststatus = 2
|
|
vim.opt.scrolloff = 5
|
|
vim.opt.ignorecase = true
|
|
vim.opt.hlsearch = true
|
|
vim.opt.incsearch = true
|
|
vim.opt.wrap = false
|
|
vim.opt.timeoutlen = 1000
|
|
vim.opt.ttimeoutlen = 0
|
|
vim.opt.hidden = true
|
|
vim.opt.wildmenu = true
|
|
vim.opt.clipboard = "unnamed,unnamedplus"
|
|
vim.opt.colorcolumn = "75"
|
|
-- vim.opt.backspace = { "indent", "eol", "start" }
|
|
vim.opt.updatetime = 100
|
|
vim.opt.signcolumn = "auto"
|
|
vim.g.mapleader = " "
|
|
vim.g.maplocalleader = "\\"
|
|
|
|
function! ResizeIfTooWide()
|
|
let max_width = float2nr(&columns * 0.8)
|
|
|
|
if winwidth(0) > max_width
|
|
execute 'vertical resize ' . float2nr(&columns * 0.5)
|
|
endif
|
|
endfunction
|
|
|
|
----- Keybinds ------------------------------------------------------------
|
|
local map = vim.keymap.set
|
|
local NS = { noremap = true, silent = true }
|
|
map("n", "gw", ":bdelete<CR>", NS)
|
|
map("n", "K", "<Nop>", NS)
|
|
map("v", ">", ">gv", NS)
|
|
map("v", "<", "<gv", NS)
|
|
map("v", "J", ":m '>+1<CR>gv=gv", NS)
|
|
map("v", "K", ":m '<-2<CR>gv=gv", NS)
|
|
map("n", "H", ":bnext<CR>zz", NS)
|
|
map("n", "L", ":bprev<CR>zz", NS)
|
|
map("n", ",", ":copen<CR>", NS)
|
|
map("n", ">", ":cn<CR>", NS)
|
|
map("n", "<", ":cp<CR>", NS)
|
|
map("n", "\\", ":noh<CR>", NS)
|
|
map("n", "E", ":Ex<CR>", NS)
|
|
map("n", "<space>z", ":set relativenumber<CR>", NS)
|
|
map("n", "<space>x", ":set norelativenumber<CR>", NS)
|
|
map("n", "gb", ":make<CR>", NS)
|
|
map("n", "gs", ":w<CR>", NS)
|
|
map("n", "ghp", ":Gitsigns preview_hunk_inline<CR>", NS)
|
|
map("n", "gs", ":w<CR>", NS)
|
|
map('n', '<leader>ff', function() require('telescope.builtin').find_files() end, NS)
|
|
map('n', '<leader>fg', function() require('telescope.builtin').live_grep() end, NS)
|
|
map('x', '<leader>ga', function() require('align').align_to_string({ preview = true, regex = false }) end, NS)
|
|
map({'i'}, '<C-K>', function() require('luasnip').expand() end, NS)
|
|
map({'i', 's'}, '<C-L>', function() require('luasnip').jump( 1) end, NS)
|
|
map({'i', 's'}, '<C-J>', function() require('luasnip').jump(-1) end, NS)
|
|
map({'i', 's'}, '<C-E>', function() if require('luasnip').choice_active() then require('luasnip').change_choice(1) end end, NS)
|
|
map("n", "#", ":execute 'vertical resize ' . float2nr(&columns * 0.9)<CR>", NS)
|