Update nvim.
This commit is contained in:
1 parent
78ec20d721
commit
69214f1c11
1 file changed
+62
-130
+62
-130
@@ -1,3 +1,4 @@
|
|||||||
|
----- Plugins -------------------------------------------------------------
|
||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||||
@@ -14,9 +15,6 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
|||||||
end
|
end
|
||||||
vim.opt.rtp:prepend(lazypath)
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
vim.g.mapleader = " "
|
|
||||||
vim.g.maplocalleader = "\\"
|
|
||||||
|
|
||||||
require("lazy").setup({
|
require("lazy").setup({
|
||||||
spec = {
|
spec = {
|
||||||
{
|
{
|
||||||
@@ -37,140 +35,74 @@ require("lazy").setup({
|
|||||||
'nvim-lua/plenary.nvim',
|
'nvim-lua/plenary.nvim',
|
||||||
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' },
|
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' },
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
'Vonr/align.nvim',
|
||||||
|
branch = "v2",
|
||||||
|
lazy = true,
|
||||||
|
init = function()
|
||||||
|
-- mappings here...
|
||||||
|
end
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
install = { colorscheme = { "habamax" } },
|
install = { colorscheme = { "habamax" } },
|
||||||
checker = { enabled = false }, -- automatic updates
|
checker = { enabled = false }, -- automatic updates
|
||||||
})
|
})
|
||||||
|
|
||||||
|
----- Settings ------------------------------------------------------------
|
||||||
|
|
||||||
vim.cmd("filetype plugin indent on")
|
vim.cmd("filetype plugin indent on")
|
||||||
|
vim.cmd("colorscheme habamax") -- or wildchart
|
||||||
--vim.cmd("syntax off")
|
vim.opt.backup = false
|
||||||
|
vim.opt.writebackup = false
|
||||||
-- vim.cmd("colorscheme wildcharm")
|
vim.opt.swapfile = false
|
||||||
vim.cmd("colorscheme habamax")
|
vim.opt.number = true
|
||||||
|
vim.opt.tabstop = 8
|
||||||
vim.opt.backup = false
|
vim.opt.shiftwidth = 4
|
||||||
vim.opt.writebackup = false
|
vim.opt.softtabstop = 4
|
||||||
vim.opt.swapfile = false
|
vim.opt.expandtab = true
|
||||||
|
vim.opt.autoindent = true
|
||||||
vim.opt.number = true
|
vim.opt.smarttab = true
|
||||||
|
vim.opt.mouse = "a"
|
||||||
vim.opt.tabstop = 8
|
vim.opt.laststatus = 2
|
||||||
vim.opt.shiftwidth = 4
|
vim.opt.scrolloff = 5
|
||||||
vim.opt.softtabstop = 4
|
vim.opt.ignorecase = true
|
||||||
vim.opt.expandtab = true
|
vim.opt.hlsearch = true
|
||||||
vim.opt.autoindent = true
|
vim.opt.incsearch = true
|
||||||
vim.opt.smarttab = true
|
vim.opt.wrap = false
|
||||||
|
vim.opt.timeoutlen = 1000
|
||||||
vim.opt.mouse = "a"
|
vim.opt.ttimeoutlen = 0
|
||||||
|
vim.opt.hidden = true
|
||||||
vim.opt.laststatus = 2
|
vim.opt.wildmenu = true
|
||||||
|
vim.opt.clipboard = "unnamed,unnamedplus"
|
||||||
vim.opt.scrolloff = 5
|
vim.opt.colorcolumn = "75"
|
||||||
|
|
||||||
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.backspace = { "indent", "eol", "start" }
|
||||||
|
vim.opt.updatetime = 100
|
||||||
|
vim.opt.signcolumn = "auto"
|
||||||
|
vim.g.mapleader = " "
|
||||||
|
vim.g.maplocalleader = "\\"
|
||||||
|
|
||||||
vim.opt.updatetime = 100
|
----- Keybinds ------------------------------------------------------------
|
||||||
vim.opt.signcolumn = "auto"
|
|
||||||
|
|
||||||
local map = vim.keymap.set
|
local map = vim.keymap.set
|
||||||
|
local NS = { noremap = true, silent = true }
|
||||||
map("n", "K", "<Nop>", { silent = true })
|
map("n", "K", "<Nop>", NS)
|
||||||
|
map("v", ">", ">gv", NS)
|
||||||
map("v", ">", ">gv", { silent = true })
|
map("v", "<", "<gv", NS)
|
||||||
map("v", "<", "<gv", { silent = true })
|
map("v", "J", ":m '>+1<CR>gv=gv", NS)
|
||||||
|
map("v", "K", ":m '<-2<CR>gv=gv", NS)
|
||||||
map("v", "J", ":m '>+1<CR>gv=gv", { silent = true })
|
map("n", "H", ":bnext<CR>zz", NS)
|
||||||
map("v", "K", ":m '<-2<CR>gv=gv", { silent = true })
|
map("n", "L", ":bprev<CR>zz", NS)
|
||||||
|
map("n", ",", ":copen<CR>", NS)
|
||||||
map("n", "H", ":bnext<CR>zz", { silent = true })
|
map("n", ">", ":cn<CR>", NS)
|
||||||
map("n", "L", ":bprev<CR>zz", { silent = true })
|
map("n", "<", ":cp<CR>", NS)
|
||||||
|
map("n", "\\", ":noh<CR>", NS)
|
||||||
map("n", ",", ":copen<CR>", { silent = true })
|
map("n", "E", ":Ex<CR>", NS)
|
||||||
map("n", ">", ":cn<CR>", { silent = true })
|
map("n", "<space>z", ":set relativenumber<CR>", NS)
|
||||||
map("n", "<", ":cp<CR>", { silent = true })
|
map("n", "<space>x", ":set norelativenumber<CR>", NS)
|
||||||
|
map("n", "gb", ":make<CR>", NS)
|
||||||
map("n", "\\", ":noh<CR>", { silent = true })
|
map("n", "gs", ":w<CR>", NS)
|
||||||
|
map("n", "ghp", ":Gitsigns preview_hunk_inline<CR>", NS)
|
||||||
map("n", "E", ":Ex<CR>", { silent = true })
|
map("n", "gs", ":w<CR>", NS)
|
||||||
|
map('n', '<leader>ff', function() require('telescope.builtin').find_files() end, NS)
|
||||||
map("n", "<space>z", ":set relativenumber<CR>", { silent = true })
|
map('n', '<leader>fg', function() require('telescope.builtin').live_grep() end, NS)
|
||||||
map("n", "<space>x", ":set norelativenumber<CR>", { silent = true })
|
map('x', '<leader>ga', function() require('align').align_to_string({ preview = true, regex = false }) end, NS)
|
||||||
|
|
||||||
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