Update settings
This commit is contained in:
22
lua/core/autocmds.lua
Normal file
22
lua/core/autocmds.lua
Normal file
@@ -0,0 +1,22 @@
|
||||
local api = vim.api
|
||||
|
||||
-- Set cargo for .rs files
|
||||
api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
|
||||
pattern = { "*.rs" },
|
||||
command = "compiler cargo"
|
||||
})
|
||||
|
||||
-- Indentation for .go files
|
||||
api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
|
||||
pattern = { "*.go" },
|
||||
callback = function()
|
||||
vim.cmd [[Tabs 4]]
|
||||
vim.cmd [[set nolist]]
|
||||
end
|
||||
})
|
||||
|
||||
-- Set tsc for .ts files
|
||||
api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
|
||||
pattern = { "*.ts", "*.tsx" },
|
||||
command = "compiler tsc"
|
||||
})
|
||||
23
lua/core/commands.lua
Normal file
23
lua/core/commands.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
local api, opt = vim.api, vim.opt
|
||||
|
||||
local function indent(n, expand)
|
||||
local size = 4
|
||||
if n ~= "" then size = n end
|
||||
|
||||
local num = tonumber(size)
|
||||
if num then
|
||||
size = num
|
||||
end
|
||||
|
||||
opt.expandtab = expand
|
||||
opt.shiftwidth = size
|
||||
opt.tabstop = size
|
||||
end
|
||||
|
||||
api.nvim_create_user_command("Tabs", function(v)
|
||||
indent(v.args, false)
|
||||
end, { nargs = "?" })
|
||||
|
||||
api.nvim_create_user_command("Spaces", function(v)
|
||||
indent(v.args, true)
|
||||
end, { nargs = "?" })
|
||||
@@ -1,50 +1,4 @@
|
||||
local opt, g, api =
|
||||
vim.opt,
|
||||
vim.g,
|
||||
vim.api
|
||||
|
||||
-- Disable netrw
|
||||
-- g.loaded_netrw = 1
|
||||
-- g.loaded_netrwPlugin = 1
|
||||
|
||||
-- Settings
|
||||
g.mapleader = " "
|
||||
g.maplocalleader = ","
|
||||
|
||||
opt.backup = false
|
||||
opt.swapfile = false
|
||||
opt.termguicolors = true
|
||||
opt.number = true
|
||||
opt.relativenumber = true
|
||||
opt.mouse = "a"
|
||||
opt.hidden = true
|
||||
opt.scrolloff = 8
|
||||
|
||||
-- Indentation
|
||||
opt.expandtab = true
|
||||
opt.smartindent = true
|
||||
opt.shiftwidth = 4
|
||||
opt.tabstop = 4
|
||||
|
||||
-- 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
|
||||
|
||||
opt.expandtab = expand
|
||||
opt.shiftwidth = size
|
||||
opt.tabstop = size
|
||||
end
|
||||
|
||||
api.nvim_create_user_command("Tabs", function(v)
|
||||
indent(v.args, false)
|
||||
end, { nargs = "?" })
|
||||
|
||||
api.nvim_create_user_command("Spaces", function(v)
|
||||
indent(v.args, true)
|
||||
end, { nargs = "?" })
|
||||
require "core.settings"
|
||||
require "core.commands"
|
||||
require "core.autocmds"
|
||||
require "core.keys"
|
||||
|
||||
23
lua/core/keys.lua
Normal file
23
lua/core/keys.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
local function map(mode, lhs, rhs)
|
||||
vim.api.nvim_set_keymap(mode, lhs, rhs, {})
|
||||
end
|
||||
|
||||
-- Buffer navigation
|
||||
map("n", "<Tab>", ":bnext<CR>")
|
||||
map("n", "<S-Tab>", ":bprevious<CR>")
|
||||
map("n", "<leader>x", ":bd!<CR>")
|
||||
|
||||
-- Resize buffer splits
|
||||
map("n", "<S-Left>", ":vertical resize +3<CR>")
|
||||
map("n", "<S-Right>", ":vertical resize -3<CR>")
|
||||
map("n", "<S-Down>", ":horizontal resize +3<CR>")
|
||||
map("n", "<S-Up>", ":horizontal resize -3<CR>")
|
||||
|
||||
-- Netrw
|
||||
map("n", "<C-n>", ":Exp<CR>")
|
||||
|
||||
-- Remove highlights
|
||||
map("n", "<leader>h", ":noh<CR>")
|
||||
|
||||
-- Replace (visual)
|
||||
map("v", "<leader>r", "\"hy:%s/<C-r>h//g<left><left>")
|
||||
40
lua/core/settings.lua
Normal file
40
lua/core/settings.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
local g, opt = vim.g, vim.opt
|
||||
|
||||
-- Settings
|
||||
g.mapleader = " "
|
||||
g.maplocalleader = ","
|
||||
|
||||
opt.backup = false
|
||||
opt.swapfile = false
|
||||
opt.termguicolors = true
|
||||
opt.number = true
|
||||
opt.relativenumber = true
|
||||
opt.scrolloff = 8
|
||||
opt.sidescrolloff = 8
|
||||
opt.title = true
|
||||
-- opt.titlestring = "filename [+=-] - NVIM"
|
||||
opt.wrap = false
|
||||
opt.clipboard = "unnamedplus"
|
||||
opt.splitbelow = true
|
||||
opt.splitright = true
|
||||
opt.showmode = false
|
||||
|
||||
opt.grepprg = "rg --vimgrep --smart-case"
|
||||
opt.path = ".,**"
|
||||
|
||||
-- Netrw
|
||||
g.netrw_banner = 0
|
||||
|
||||
-- Indentation
|
||||
opt.expandtab = true
|
||||
opt.smartindent = true
|
||||
opt.shiftwidth = 4
|
||||
opt.tabstop = 4
|
||||
opt.list = true
|
||||
opt.listchars = "lead:·"
|
||||
|
||||
-- Search
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.smartcase = true
|
||||
vim.opt.hlsearch = true
|
||||
vim.opt.incsearch = true
|
||||
Reference in New Issue
Block a user