Refactor configuration.
This commit is contained in:
83
init.lua
83
init.lua
@@ -25,7 +25,7 @@ vim.o.smartcase = true
|
||||
vim.o.hlsearch = true
|
||||
vim.o.incsearch = true
|
||||
|
||||
vim.o.wildignore = "**/node_modules/**"
|
||||
vim.o.wildignore = "**/node_modules/**,*.o"
|
||||
vim.o.path = ".,**"
|
||||
|
||||
-- Keybindings
|
||||
@@ -36,87 +36,14 @@ vim.keymap.set("n", "<leader>x", ":bd!<CR>")
|
||||
vim.keymap.set("n", "<leader>h", ":noh<CR>")
|
||||
vim.keymap.set("n", "<C-n>", ":Exp<CR>")
|
||||
|
||||
vim.keymap.set("n", "<leader>ff", function() Snacks.picker.files({ cmd = "fd" }) end)
|
||||
vim.keymap.set("n", "<leader>fw", function() Snacks.picker.grep() end)
|
||||
|
||||
vim.keymap.set("n", "<leader>.", function() Snacks.scratch() end)
|
||||
vim.keymap.set("n", "<leader>S", function() Snacks.scratch.select() end)
|
||||
|
||||
vim.keymap.set("n", "<leader>gb", function() Snacks.git.blame_line() end)
|
||||
|
||||
-- Commands
|
||||
local function indent(n, expand)
|
||||
local size = 4
|
||||
if n ~= "" then size = n end
|
||||
|
||||
local num = tonumber(size)
|
||||
if num then
|
||||
size = num
|
||||
end
|
||||
|
||||
vim.o.expandtab = expand
|
||||
vim.o.shiftwidth = size
|
||||
vim.o.tabstop = size
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("Tabs", function(v)
|
||||
indent(v.args, false)
|
||||
end, { nargs = "?" })
|
||||
|
||||
vim.api.nvim_create_user_command("Spaces", function(v)
|
||||
indent(v.args, true)
|
||||
end, { nargs = "?" })
|
||||
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
vim.cmd [[
|
||||
hi Normal guibg=none ctermbg=none
|
||||
hi NonText guibg=none ctermbg=none
|
||||
hi NormalFloat guibg=none ctermbg=none
|
||||
]]
|
||||
end
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("TE", function(v)
|
||||
vim.cmd("split")
|
||||
vim.cmd("term " .. v.args)
|
||||
end, { nargs = "*", force = true })
|
||||
|
||||
-- autocmd
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
|
||||
pattern = { "*.ts", "*.tsx" },
|
||||
command = "compiler tsc"
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
|
||||
pattern = "*.go",
|
||||
command = "Tabs 4"
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
|
||||
pattern = "*.rs",
|
||||
command = "compiler cargo"
|
||||
})
|
||||
-- Imports
|
||||
require "core.commands"
|
||||
require "core.autocmds"
|
||||
|
||||
-- Plugins
|
||||
vim.pack.add({
|
||||
{ src = "https://github.com/wakatime/vim-wakatime" },
|
||||
{ src = "https://github.com/folke/snacks.nvim" }
|
||||
{ src = "https://github.com/wakatime/vim-wakatime" }
|
||||
})
|
||||
|
||||
-- Snacks
|
||||
require("snacks").setup {
|
||||
git = {
|
||||
enabled = true,
|
||||
border = "rounded"
|
||||
},
|
||||
picker = {
|
||||
enabled = true,
|
||||
ui_select = true
|
||||
},
|
||||
scratch = { enabled = true }
|
||||
}
|
||||
|
||||
-- Theme
|
||||
vim.cmd [[colorscheme default]]
|
||||
|
||||
25
lua/core/autocmds.lua
Normal file
25
lua/core/autocmds.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
vim.cmd [[
|
||||
hi Normal guibg=none ctermbg=none
|
||||
hi NonText guibg=none ctermbg=none
|
||||
hi NormalFloat guibg=none ctermbg=none
|
||||
]]
|
||||
end
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
|
||||
pattern = { "*.ts", "*.tsx" },
|
||||
command = "compiler tsc"
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
|
||||
pattern = "*.go",
|
||||
command = "Tabs 4"
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
|
||||
pattern = "*.rs",
|
||||
command = "compiler cargo"
|
||||
})
|
||||
26
lua/core/commands.lua
Normal file
26
lua/core/commands.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
local function indent(n, expand)
|
||||
local size = 4
|
||||
if n ~= "" then size = n end
|
||||
|
||||
local num = tonumber(size)
|
||||
if num then
|
||||
size = num
|
||||
end
|
||||
|
||||
vim.o.expandtab = expand
|
||||
vim.o.shiftwidth = size
|
||||
vim.o.tabstop = size
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("Tabs", function(v)
|
||||
indent(v.args, false)
|
||||
end, { nargs = "?" })
|
||||
|
||||
vim.api.nvim_create_user_command("Spaces", function(v)
|
||||
indent(v.args, true)
|
||||
end, { nargs = "?" })
|
||||
|
||||
vim.api.nvim_create_user_command("TE", function(v)
|
||||
vim.cmd("split")
|
||||
vim.cmd("term " .. v.args)
|
||||
end, { nargs = "*", force = true })
|
||||
8
nvim-pack-lock.json
Normal file
8
nvim-pack-lock.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"plugins": {
|
||||
"vim-wakatime": {
|
||||
"rev": "d7973b1",
|
||||
"src": "https://github.com/wakatime/vim-wakatime"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user