Add new neovim config
This commit is contained in:
parent
8a71bb62a3
commit
c7868ff459
0
nvim-new/plugin/+plugins.lua
Normal file
0
nvim-new/plugin/+plugins.lua
Normal file
35
nvim-new/plugin/autocmds.lua
Normal file
35
nvim-new/plugin/autocmds.lua
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
local autocmd = vim.api.nvim_create_autocmd
|
||||||
|
local augroup = vim.api.nvim_create_augroup
|
||||||
|
|
||||||
|
local highlight_grp = augroup("kickstart-highlight-yank", { clear = true })
|
||||||
|
autocmd("TextYankPost", {
|
||||||
|
desc = "Highlight when yanking (copying) text",
|
||||||
|
group = highlight_grp,
|
||||||
|
callback = function()
|
||||||
|
vim.hl.on_yank()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
autocmd({ "BufWritePre" }, {
|
||||||
|
pattern = { "*" },
|
||||||
|
command = [[%s/\s\+$//e]],
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Filetype detection
|
||||||
|
|
||||||
|
local filetype_maps = {
|
||||||
|
{ pattern = "*.tf", ft = "terraform" },
|
||||||
|
{ pattern = "*.pro", ft = "progruard" },
|
||||||
|
{ pattern = "*.mjml", ft = "html" },
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, mapping in ipairs(filetype_maps) do
|
||||||
|
autocmd({ "BufRead", "BufNewFile" }, {
|
||||||
|
desc = string.format("Enforce filetype for %s", mapping["pattern"]),
|
||||||
|
pattern = { mapping["pattern"] },
|
||||||
|
callback = function()
|
||||||
|
vim.opt.filetype = mapping["ft"]
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
49
nvim-new/plugin/config.lua
Normal file
49
nvim-new/plugin/config.lua
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
local opt = vim.opt
|
||||||
|
|
||||||
|
-- Columns and gutters
|
||||||
|
opt.colorcolumn = "80" -- Highlight column 80
|
||||||
|
opt.number = true -- Line numbers in the gutter
|
||||||
|
opt.relativenumber = true -- Relative line numbers in the gutter
|
||||||
|
opt.signcolumn = "yes:1" -- Sign column in the gutter always visible
|
||||||
|
|
||||||
|
-- Indentation
|
||||||
|
opt.autoindent = true -- Enable auto-indentation
|
||||||
|
opt.breakindent = true -- ?
|
||||||
|
opt.expandtab = true -- Default to spaces instead of tabs
|
||||||
|
opt.shiftround = true -- Round indent to multiple of shift-width
|
||||||
|
opt.shiftwidth = 4 -- Number of spaces when auto-indenting
|
||||||
|
opt.softtabstop = 4 -- Number of spaces for a tab when editing
|
||||||
|
opt.tabstop = 4 -- Number of spaces for a tab
|
||||||
|
|
||||||
|
-- Display and adornments
|
||||||
|
opt.cursorline = true -- Highlight current line
|
||||||
|
opt.guifont = "Inconsolata Patched G:h12"
|
||||||
|
opt.list = true -- Show whitespace characters
|
||||||
|
opt.listchars = { tab = "» ", trail = "○", nbsp = "␣", lead = "•" }
|
||||||
|
opt.scrolloff = 3 -- Show 3 lines above and below cursor
|
||||||
|
opt.showmode = false -- Don't show the mode since it's in our statusline
|
||||||
|
opt.termguicolors = true -- Use true terminal colors
|
||||||
|
opt.virtualedit = "block"
|
||||||
|
opt.winborder = "rounded" -- Rounded borders for windows
|
||||||
|
|
||||||
|
-- Behavior
|
||||||
|
opt.confirm = true
|
||||||
|
opt.ignorecase = true -- Ignore case in search and commands
|
||||||
|
opt.inccommand = "split" -- Preview substitutions live
|
||||||
|
opt.mouse = "a" -- Turn on mouse support
|
||||||
|
opt.smartcase = true -- ?
|
||||||
|
opt.splitbelow = true
|
||||||
|
opt.splitright = true
|
||||||
|
opt.timeoutlen = 1000 -- Command timeout length
|
||||||
|
opt.undofile = true
|
||||||
|
opt.updatetime = 250 -- ?
|
||||||
|
|
||||||
|
-- Clipboard
|
||||||
|
-- Sync clipboard between OS and Neovim.
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.opt.clipboard = "unnamedplus"
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Features
|
||||||
|
vim.cmd.filetype("plugin indent on")
|
||||||
|
vim.g.have_nerd_font = true
|
||||||
26
nvim-new/plugin/keymaps.lua
Normal file
26
nvim-new/plugin/keymaps.lua
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
local keymap = vim.keymap.set
|
||||||
|
|
||||||
|
-- Globals
|
||||||
|
vim.g.mapleader = " "
|
||||||
|
vim.g.maplocalleader = " "
|
||||||
|
vim.g.loaded_netrw = 1
|
||||||
|
vim.g.loaded_netrwPlugin = 1
|
||||||
|
|
||||||
|
-- Normal mode
|
||||||
|
keymap("n", "<Esc>", "<cmd>nohlsearch<CR>")
|
||||||
|
keymap("n", "<leader>f", vim.diagnostic.setloclist, { desc = "Open diagnostic quick[f]ix list" })
|
||||||
|
keymap("n", "<leader>w", "<cmd>w!<CR>", { desc = "[w]rite current file", silent = true })
|
||||||
|
keymap("n", "<leader>q", "<cmd>q<CR>", { desc = "[q]uit current buffer", silent = true })
|
||||||
|
keymap("n", "<leader>Q", "<cmd>qa<CR>", { desc = "[Q]uit completely", silent = true })
|
||||||
|
keymap("n", "<Leader>fb", ":lua vim.lsp.buf.format()<CR>", { desc = "[f]ormat [b]uffer", silent = true })
|
||||||
|
keymap("n", "<C-h>", "<C-w><C-h>", { desc = "Move focus to the left window" })
|
||||||
|
keymap("n", "<C-l>", "<C-w><C-l>", { desc = "Move focus to the right window" })
|
||||||
|
keymap("n", "<C-j>", "<C-w><C-j>", { desc = "Move focus to the lower window" })
|
||||||
|
keymap("n", "<C-k>", "<C-w><C-k>", { desc = "Move focus to the upper window" })
|
||||||
|
keymap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", { desc = "[g]o to [d]efinition", noremap = true, silent = true })
|
||||||
|
|
||||||
|
-- Visual mode
|
||||||
|
keymap("v", "<Leader>p", '"_dP', { desc = "[p]aste without overwriting default register" })
|
||||||
|
|
||||||
|
-- Terminal mode
|
||||||
|
keymap("t", "<Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" })
|
||||||
0
nvim-new/plugin/statusline.lua
Normal file
0
nvim-new/plugin/statusline.lua
Normal file
@ -37,6 +37,8 @@ alias av="ansible-vault"
|
|||||||
# tool aliases
|
# tool aliases
|
||||||
if [[ -x "$(command -v nvim)" ]]; then
|
if [[ -x "$(command -v nvim)" ]]; then
|
||||||
alias vim="nvim"
|
alias vim="nvim"
|
||||||
|
alias v="nvim"
|
||||||
|
alias vv="NVIM_APPNAME=nvim-new nvim"
|
||||||
fi
|
fi
|
||||||
if [[ -x "$(command -v highlight)" ]]; then
|
if [[ -x "$(command -v highlight)" ]]; then
|
||||||
alias ccat='highlight -O ansi --force'
|
alias ccat='highlight -O ansi --force'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user