Nvim.
This commit is contained in:
1 parent
d4c25ea6cb
commit
78ec20d721
2 files changed
+176
-94
No files matched your search
+176
@@ -0,0 +1,176 @@
|
||||
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)
|
||||
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = "\\"
|
||||
|
||||
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' },
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
install = { colorscheme = { "habamax" } },
|
||||
checker = { enabled = false }, -- automatic updates
|
||||
})
|
||||
|
||||
|
||||
|
||||
vim.cmd("filetype plugin indent on")
|
||||
|
||||
--vim.cmd("syntax off")
|
||||
|
||||
-- vim.cmd("colorscheme wildcharm")
|
||||
vim.cmd("colorscheme habamax")
|
||||
|
||||
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"
|
||||
|
||||
local map = vim.keymap.set
|
||||
|
||||
map("n", "K", "<Nop>", { silent = true })
|
||||
|
||||
map("v", ">", ">gv", { silent = true })
|
||||
map("v", "<", "<gv", { silent = true })
|
||||
|
||||
map("v", "J", ":m '>+1<CR>gv=gv", { silent = true })
|
||||
map("v", "K", ":m '<-2<CR>gv=gv", { silent = true })
|
||||
|
||||
map("n", "H", ":bnext<CR>zz", { silent = true })
|
||||
map("n", "L", ":bprev<CR>zz", { silent = true })
|
||||
|
||||
map("n", ",", ":copen<CR>", { silent = true })
|
||||
map("n", ">", ":cn<CR>", { silent = true })
|
||||
map("n", "<", ":cp<CR>", { silent = true })
|
||||
|
||||
map("n", "\\", ":noh<CR>", { silent = true })
|
||||
|
||||
map("n", "E", ":Ex<CR>", { silent = true })
|
||||
|
||||
map("n", "<space>z", ":set relativenumber<CR>", { silent = true })
|
||||
map("n", "<space>x", ":set norelativenumber<CR>", { silent = true })
|
||||
|
||||
map("n", "gb", ":make<CR>", { silent = true })
|
||||
map("n", "gs", ":w<CR>", { silent = true })
|
||||
|
||||
map("n", "ghp", ":Gitsigns preview_hunk_inline<CR>", { silent = true })
|
||||
map("n", "gs", ":w<CR>", { silent = true })
|
||||
|
||||
local builtin = require('telescope.builtin')
|
||||
map('n', '<leader>ff', builtin.find_files, { desc = 'Telescope find files' })
|
||||
map('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope live grep' })
|
||||
|
||||
-- Align command
|
||||
local function align_line(line, sep, maxpos, extra)
|
||||
local lhs, rhs = line:match("^(.-)%s*(" .. sep .. ".*)$")
|
||||
|
||||
if not lhs then
|
||||
return line
|
||||
end
|
||||
|
||||
local spaces = string.rep(" ", maxpos - #lhs + extra)
|
||||
return lhs .. spaces .. rhs
|
||||
end
|
||||
|
||||
local function align_section(opts)
|
||||
local sep = opts.args ~= "" and opts.args or "="
|
||||
local extra = 1
|
||||
|
||||
local lines = vim.api.nvim_buf_get_lines(
|
||||
0,
|
||||
opts.line1 - 1,
|
||||
opts.line2,
|
||||
false
|
||||
)
|
||||
|
||||
local maxpos = 0
|
||||
|
||||
for _, line in ipairs(lines) do
|
||||
local s, _ = line:find("%s*" .. sep)
|
||||
if s and (s - 1) > maxpos then
|
||||
maxpos = s - 1
|
||||
end
|
||||
end
|
||||
|
||||
for i, line in ipairs(lines) do
|
||||
lines[i] = align_line(line, sep, maxpos, extra)
|
||||
end
|
||||
|
||||
vim.api.nvim_buf_set_lines(
|
||||
0,
|
||||
opts.line1 - 1,
|
||||
opts.line2,
|
||||
false,
|
||||
lines
|
||||
)
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("Align", align_section, {
|
||||
nargs = "?",
|
||||
range = true,
|
||||
})
|
||||
|
||||
map("v", "<Leader>a", ":Align<CR>", { silent = true })
|
||||
Reference in new issue
Block a user