chillin
This commit is contained in:
61
configs/dotfiles/nvim/lua/config/autocmd.lua
Normal file
61
configs/dotfiles/nvim/lua/config/autocmd.lua
Normal file
@@ -0,0 +1,61 @@
|
||||
local augroup = vim.api.nvim_create_augroup
|
||||
local gib_group = augroup('Gib', {})
|
||||
local autocmd = vim.api.nvim_create_autocmd
|
||||
local createcmd = vim.api.nvim_create_user_command
|
||||
local yank_group = augroup('HighlightYank', {})
|
||||
|
||||
function R(name)
|
||||
require("plenary.reload").reload_module(name)
|
||||
end
|
||||
|
||||
autocmd('TextYankPost', {
|
||||
group = yank_group,
|
||||
pattern = '*',
|
||||
callback = function()
|
||||
vim.highlight.on_yank({
|
||||
higroup = 'IncSearch',
|
||||
timeout = 40,
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
autocmd({"BufWritePre"}, {
|
||||
group = gib_group,
|
||||
pattern = "*",
|
||||
command = [[%s/\s\+$//e]],
|
||||
})
|
||||
|
||||
autocmd({'BufWritePost'}, {
|
||||
pattern = 'init.lua',
|
||||
command = 'source <afile>',
|
||||
})
|
||||
|
||||
autocmd('LspAttach', {
|
||||
group = gib_group,
|
||||
callback = function(e)
|
||||
local opts = { buffer = e.buf }
|
||||
vim.keymap.set('n', '<leader>kf', vim.lsp.buf.format)
|
||||
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
|
||||
vim.keymap.set("n", "<leader>kw", function() vim.lsp.buf.workspace_symbol() end, opts)
|
||||
vim.keymap.set("n", "<leader>kd", function() vim.diagnostic.open_float() end, opts)
|
||||
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
|
||||
vim.keymap.set("n", "<leader>re", function() vim.lsp.buf.references() end, opts)
|
||||
vim.keymap.set("n", "<leader>rn", function() vim.lsp.buf.rename() end, opts)
|
||||
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
|
||||
end
|
||||
})
|
||||
|
||||
createcmd("Format", function(args)
|
||||
local range
|
||||
if args.count ~= -1 then
|
||||
local start_line = vim.fn.line("'<")
|
||||
local end_line = vim.fn.line("'>")
|
||||
range = { start = { start_line, 0 }, ["end"] = { end_line, 0 } }
|
||||
end
|
||||
require("conform").format({
|
||||
async = true,
|
||||
lsp_fallback = true, -- if no external formatter, use LSP
|
||||
range = range,
|
||||
})
|
||||
end, { range = true, desc = "Format current buffer or range" })
|
||||
vim.keymap.set({ "n", "v" }, "<leader>fk", ":Format<CR>", { silent = true, desc = "Format" })
|
@@ -1,65 +1,4 @@
|
||||
require('config.set')
|
||||
require('config.remap')
|
||||
require("config.lazy")
|
||||
|
||||
local augroup = vim.api.nvim_create_augroup
|
||||
local GibGroup = augroup('Gib', {})
|
||||
|
||||
local autocmd = vim.api.nvim_create_autocmd
|
||||
local yank_group = augroup('HighlightYank', {})
|
||||
|
||||
function R(name)
|
||||
require("plenary.reload").reload_module(name)
|
||||
end
|
||||
|
||||
vim.filetype.add({
|
||||
extension = {
|
||||
templ = 'templ',
|
||||
}
|
||||
})
|
||||
|
||||
autocmd('TextYankPost', {
|
||||
group = yank_group,
|
||||
pattern = '*',
|
||||
callback = function()
|
||||
vim.highlight.on_yank({
|
||||
higroup = 'IncSearch',
|
||||
timeout = 40,
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
autocmd({"BufWritePre"}, {
|
||||
group = GibGroup,
|
||||
pattern = "*",
|
||||
command = [[%s/\s\+$//e]],
|
||||
})
|
||||
|
||||
autocmd('BufEnter', {
|
||||
group = GibGroup,
|
||||
callback = function()
|
||||
if vim.bo.filetype == "zig" then
|
||||
vim.cmd.colorscheme("tokyonight-moon")
|
||||
else
|
||||
vim.cmd.colorscheme("tokyonight-moon")
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
autocmd('LspAttach', {
|
||||
group = GibGroup,
|
||||
callback = function(e)
|
||||
local opts = { buffer = e.buf }
|
||||
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
|
||||
vim.keymap.set("n", "<leader>H", function() vim.lsp.buf.hover() end, opts)
|
||||
vim.keymap.set("n", "<leader>kw", function() vim.lsp.buf.workspace_symbol() end, opts)
|
||||
vim.keymap.set("n", "<leader>kd", function() vim.diagnostic.open_float() end, opts)
|
||||
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
|
||||
vim.keymap.set("n", "<leader>re", function() vim.lsp.buf.references() end, opts)
|
||||
vim.keymap.set("n", "<leader>rn", function() vim.lsp.buf.rename() end, opts)
|
||||
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
|
||||
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
|
||||
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
|
||||
end
|
||||
})
|
||||
require('config.options')
|
||||
require('config.keymaps')
|
||||
require('plugins')
|
||||
require('config.autocmd')
|
||||
|
40
configs/dotfiles/nvim/lua/config/keymaps.lua
Normal file
40
configs/dotfiles/nvim/lua/config/keymaps.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
vim.g.mapleader = ' '
|
||||
vim.keymap.set('n', '<leader><leader>s', ':update<CR> :source<CR>')
|
||||
vim.keymap.set('n', '<leader><leader>x', ':!chmod +x %<CR>', { silent = true })
|
||||
vim.keymap.set({'n', 'v', 'x'}, '<leader>h', '<C-w>h')
|
||||
vim.keymap.set({'n', 'v', 'x'}, '<leader>j', '<C-w>j')
|
||||
vim.keymap.set({'n', 'v', 'x'}, '<leader>k', '<C-w>k')
|
||||
vim.keymap.set({'n', 'v', 'x'}, '<leader>l', '<C-w>l')
|
||||
vim.keymap.set('n', '<leader>w', ':write<CR>')
|
||||
vim.keymap.set('n', '<leader>q', ':quit<CR>')
|
||||
-- Move the selected lines up or down one line and reselect
|
||||
vim.keymap.set('v', 'J', ':m \'>+1<CR>gv=gv')
|
||||
vim.keymap.set('v', 'K', ':m \'<-2<CR>gv=gv')
|
||||
-- Join the current line with the line below and reposition the cursor
|
||||
vim.keymap.set('n', 'J', 'mzJ`z')
|
||||
-- Scroll down or up and reposition the cursor
|
||||
vim.keymap.set('n', '<C-d>', '<C-d>zz')
|
||||
vim.keymap.set('n', '<C-u>', '<C-u>zz')
|
||||
-- Search forward and reposition the cursor
|
||||
vim.keymap.set('n', 'n', 'nzzzv')
|
||||
-- Search backward and reposition the cursor
|
||||
vim.keymap.set('n', 'N', 'Nzzzv')
|
||||
-- Paste the selection from the system clipboard
|
||||
vim.keymap.set({'n', 'v', 'x'}, '<leader>p', [["+p]])
|
||||
vim.keymap.set({'n', 'v', 'x'}, '<leader>P', [["+P]])
|
||||
-- Move selected text to the black hole register & replace with copied text.
|
||||
vim.keymap.set('x', '<leader>v', [["_dP]])
|
||||
-- Yank (copy) the selection to the system clipboard
|
||||
vim.keymap.set({'n', 'v'}, '<leader>y', [["+y]])
|
||||
-- Yank (copy) the entire buffer to the system clipboard
|
||||
vim.keymap.set('n', '<leader>yy', [["+Y]])
|
||||
-- Yank all the text in the file to the system clipboard
|
||||
vim.keymap.set('n', '<leader>YY', 'gg"+yG')
|
||||
-- Delete the selection without yanking (copying) it
|
||||
vim.keymap.set({'n', 'v'}, '<leader>d', [["_d]])
|
||||
-- Delete the line without yanking (copying) it
|
||||
vim.keymap.set('n', '<leader>dd', [["_dd]])
|
||||
-- Map Q in Normal mode to do nothing (nop)
|
||||
vim.keymap.set('n', 'Q', '<nop>')
|
||||
-- Perform a search and replace operation using the word under the cursor
|
||||
vim.keymap.set('n', '<leader>sr', [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
|
@@ -1,27 +0,0 @@
|
||||
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 = "\\"
|
||||
|
||||
-- Setup lazy.nvim
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
{ import = 'plugins' },
|
||||
},
|
||||
install = { colorscheme = { "tokyonight-moon" } },
|
||||
-- automatically check for plugin updates
|
||||
--checker = { enabled = true },
|
||||
})
|
21
configs/dotfiles/nvim/lua/config/options.lua
Normal file
21
configs/dotfiles/nvim/lua/config/options.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
vim.o.number = true
|
||||
vim.o.relativenumber = true
|
||||
vim.o.winborder = 'rounded'
|
||||
vim.o.tabstop = 2
|
||||
vim.o.softtabstop = 2
|
||||
vim.o.shiftwidth = 2
|
||||
vim.o.expandtab = true
|
||||
vim.o.smartindent = true
|
||||
vim.o.swapfile = false
|
||||
vim.o.undodir = os.getenv('HOME') .. '/.vim/undodir'
|
||||
vim.o.undofile = true
|
||||
vim.o.hlsearch = true
|
||||
vim.o.incsearch = true
|
||||
vim.o.termguicolors = true
|
||||
vim.o.scrolloff = 4
|
||||
vim.o.signcolumn = 'yes'
|
||||
vim.o.updatetime = 50
|
||||
vim.opt.isfname:append('@-@')
|
||||
vim.cmd([[set list]])
|
||||
vim.cmd([[set listchars=trail:⋅,nbsp:⋅,tab:\ \ ]])
|
||||
vim.cmd(':hi statusline guibg=NONE')
|
@@ -1,71 +0,0 @@
|
||||
-- Remaps
|
||||
---------------------------------------------
|
||||
-- Set leader to space
|
||||
vim.g.mapleader = " "
|
||||
|
||||
-- Move the selected lines up or down one line and reselect
|
||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
|
||||
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
|
||||
|
||||
-- Join the current line with the line below and reposition the cursor
|
||||
vim.keymap.set("n", "J", "mzJ`z")
|
||||
|
||||
-- Scroll down or up and reposition the cursor
|
||||
vim.keymap.set("n", "<C-d>", "<C-d>zz")
|
||||
vim.keymap.set("n", "<C-u>", "<C-u>zz")
|
||||
|
||||
-- Search forward and reposition the cursor
|
||||
vim.keymap.set("n", "n", "nzzzv")
|
||||
|
||||
-- Search backward and reposition the cursor
|
||||
vim.keymap.set("n", "N", "Nzzzv")
|
||||
|
||||
-- Paste the selection from the system clipboard
|
||||
vim.keymap.set({"n", "v"}, "<leader>v", [["+p]])
|
||||
vim.keymap.set({"n", "v"}, "<leader>V", [["+P]])
|
||||
|
||||
-- Move selected text to the black hole register & replace with copied text.
|
||||
vim.keymap.set("x", "<leader>p", [["_dP]])
|
||||
|
||||
-- Yank (copy) the selection to the system clipboard
|
||||
vim.keymap.set({"n", "v"}, "<leader>y", [["+y]])
|
||||
|
||||
-- Yank (copy) the entire buffer to the system clipboard
|
||||
vim.keymap.set("n", "<leader>Y", [["+Y]])
|
||||
|
||||
-- Yank all the text in the file to the system clipboard
|
||||
vim.keymap.set("n", "<leader>YY", "gg\"+yG")
|
||||
|
||||
-- Delete the selection without yanking (copying) it
|
||||
vim.keymap.set({"n", "v"}, "<leader>d", [["_d]])
|
||||
|
||||
-- Delete the line without yanking (copying) it
|
||||
vim.keymap.set("n", "<leader>dd", [["_dd]])
|
||||
|
||||
-- Map Q in Normal mode to do nothing (nop)
|
||||
vim.keymap.set("n", "Q", "<nop>")
|
||||
|
||||
-- Format the current buffer using the language server protocol (LSP)
|
||||
vim.keymap.set("n", "<leader>kf", vim.lsp.buf.format)
|
||||
|
||||
-- Perform a search and replace operation using the word under the cursor
|
||||
vim.keymap.set("n", "<leader>sr", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
|
||||
|
||||
-- Make the current file executable (chmod +x)
|
||||
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })
|
||||
|
||||
-- Source the current file
|
||||
vim.keymap.set("n", "<leader><leader>", vim.cmd.so)
|
||||
|
||||
|
||||
-- Jump to the next location in the quickfix list and reposition the cursor
|
||||
-- vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz")
|
||||
|
||||
-- Jump to the previous location in the quickfix list and reposition the cursor
|
||||
-- vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz")
|
||||
|
||||
-- Jump to the next location in the location list and reposition the cursor
|
||||
--vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz")
|
||||
|
||||
-- Jump to the previous location in the location list and reposition the cursor
|
||||
--vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
|
@@ -1,34 +0,0 @@
|
||||
vim.opt.nu = true
|
||||
vim.opt.relativenumber = true
|
||||
|
||||
vim.opt.tabstop = 2
|
||||
vim.opt.softtabstop = 2
|
||||
vim.opt.shiftwidth = 2
|
||||
vim.opt.expandtab = true
|
||||
|
||||
vim.opt.smartindent = true
|
||||
|
||||
vim.opt.wrap = true
|
||||
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.backup = false
|
||||
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
|
||||
vim.opt.undofile = true
|
||||
|
||||
vim.opt.hlsearch = false
|
||||
vim.opt.incsearch = true
|
||||
|
||||
vim.opt.termguicolors = true
|
||||
|
||||
vim.opt.scrolloff = 8
|
||||
vim.opt.signcolumn = "yes"
|
||||
vim.opt.isfname:append("@-@")
|
||||
|
||||
vim.opt.updatetime = 50
|
||||
vim.cmd([[set list]])
|
||||
--vim.cmd([[set listchars=trail:⋅]])
|
||||
vim.cmd([[set listchars=trail:⋅,nbsp:⋅,tab:\ \ ]])
|
||||
|
||||
vim.opt.colorcolumn = "100"
|
||||
vim.o.background = "dark" -- or "light" for light mode
|
||||
--vim.cmd([[colorscheme tokyonight-moon]])
|
Reference in New Issue
Block a user