mirror of
https://github.com/ItsDrike/dotfiles.git
synced 2025-06-30 12:30:43 +00:00
Move non-plugin settings to core/
This commit is contained in:
parent
768764a899
commit
9c8191bfa7
7 changed files with 18 additions and 6 deletions
26
home/.config/nvim/lua/core/abbreviations.lua
Normal file
26
home/.config/nvim/lua/core/abbreviations.lua
Normal file
|
@ -0,0 +1,26 @@
|
|||
local vim = require("vim")
|
||||
local fn = vim.fn
|
||||
local m = require("utility.mappings")
|
||||
|
||||
local function cabbrev(input, result, reabbrev)
|
||||
m.abbrev("c", input, result, reabbrev)
|
||||
end
|
||||
|
||||
-- Invalid case abbreviations
|
||||
cabbrev("Wq", "wq")
|
||||
cabbrev("wQ", "wq")
|
||||
cabbrev("WQ", "wq")
|
||||
cabbrev("Wa", "wa")
|
||||
cabbrev("W", "w")
|
||||
cabbrev("Q", "q")
|
||||
cabbrev("Qall", "qall")
|
||||
cabbrev("W!", "w!")
|
||||
cabbrev("Q!", "q!")
|
||||
cabbrev("Qall!", "qall!")
|
||||
|
||||
-- Save file with sudo
|
||||
cabbrev("w!!", "w !sudo tee > /dev/null %")
|
||||
|
||||
-- Reload lua configuration
|
||||
local initlua = fn.stdpath("config") .. "init.lua"
|
||||
cabbrev("reload", "luafile " .. initlua)
|
21
home/.config/nvim/lua/core/autocmd.lua
Normal file
21
home/.config/nvim/lua/core/autocmd.lua
Normal file
|
@ -0,0 +1,21 @@
|
|||
local vim = require("vim")
|
||||
local cmd = vim.cmd
|
||||
|
||||
-- Disable automatic commenting on newlines
|
||||
cmd[[autocmd FileType * setlocal formatoptions-=cro]]
|
||||
|
||||
-- Have vim jump to last position when reopening a file
|
||||
cmd[[autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif]]
|
||||
|
||||
-- Automatically delete all trailing whitespace on save
|
||||
cmd[[autocmd BufWritePre * %s/\s\+$//e]]
|
||||
|
||||
-- Enable spellcheck for certain file types
|
||||
cmd[[autocmd FileType tex,latex,markdown,gitcommit setlocal spell spelllang=en_us]]
|
||||
|
||||
-- Use auto-wrap for certain file types at 119 chars
|
||||
cmd[[autocmd FileType markdown setlocal textwidth=119]]
|
||||
|
||||
-- Don't show line numbers in terminal
|
||||
cmd[[autocmd BufEnter term://* setlocal nonumber | setlocal norelativenumber]]
|
||||
|
7
home/.config/nvim/lua/core/init.lua
Normal file
7
home/.config/nvim/lua/core/init.lua
Normal file
|
@ -0,0 +1,7 @@
|
|||
-- Require additional scripts which contain individual configurations
|
||||
|
||||
require "core.options"
|
||||
require "core.theme"
|
||||
require "core.mappings"
|
||||
require "core.abbreviations"
|
||||
require "core.autocmd"
|
95
home/.config/nvim/lua/core/mappings.lua
Normal file
95
home/.config/nvim/lua/core/mappings.lua
Normal file
|
@ -0,0 +1,95 @@
|
|||
local m = require("utility.mappings")
|
||||
local vim = require("vim")
|
||||
local g = vim.g
|
||||
|
||||
|
||||
-- This is a bit silly, but I don't like passing the mode argument
|
||||
g.mapleader = "\\"
|
||||
|
||||
-- Unmap arrow keys in normal mode to remove bad habits
|
||||
m.keymap("n", "<Down>", "<nop>")
|
||||
m.keymap("n", "<Left>", "<nop>")
|
||||
m.keymap("n", "<Right>", "<nop>")
|
||||
m.keymap("n", "<Up>", "<nop>")
|
||||
|
||||
-- Tab navigation
|
||||
m.keymap("n", "<Tab>", "gt")
|
||||
m.keymap("n", "<S-Tab>", "gT")
|
||||
m.keymap("n", "<A-t>", ":tabnew<CR>")
|
||||
m.keymap("n", "<A-2>", ":tabmove +<CR>")
|
||||
m.keymap("n", "<A-1>", ":tabmove -<CR>")
|
||||
m.keymap("n", "<A-p>", ":tabp<CR>")
|
||||
m.keymap("n", "<A-n>", ":tabn<CR>")
|
||||
m.keymap("n", "<A-c>", ":tabc<CR>")
|
||||
|
||||
-- Buffer navigation
|
||||
m.keymap("n", "<A-N>", ":bn<CR>")
|
||||
m.keymap("n", "<A-P>", ":bp<CR>")
|
||||
m.keymap("n", "<A-d>", ":bd<CR>")
|
||||
|
||||
-- Set splits navigation to just ALT + hjkl
|
||||
m.keymap("n", "<C-h>", "<C-w>h")
|
||||
m.keymap("n", "<C-j>", "<C-w>j")
|
||||
m.keymap("n", "<C-k>", "<C-w>k")
|
||||
m.keymap("n", "<C-l>", "<C-w>l")
|
||||
|
||||
-- Split size adjusting
|
||||
m.keymap("n", "<C-Left>", ":vertical resize +3<CR>")
|
||||
m.keymap("n", "<C-Right>", ":vertical resize -3<CR>")
|
||||
m.keymap("n", "<C-Up>", ":resize +3<CR>")
|
||||
m.keymap("n", "<C-Down>", ":resize -3<CR>")
|
||||
|
||||
-- Define some common shortcuts
|
||||
m.keymap("n", "<C-s>", ":w<CR>")
|
||||
m.keymap("i", "<C-s>", "<Esc>:w<CR>i")
|
||||
m.keymap("n", "<C-z>", ":undo<CR>")
|
||||
m.keymap("n", "<C-y>", ":redo<CR>")
|
||||
|
||||
-- Terminal
|
||||
m.keymap("n", "<C-t>", ":split term://zsh<CR>:resize -7<CR>i")
|
||||
m.keymap("n", "<C-A-t>", ":vnew term://zsh<CR>i")
|
||||
m.keymap("n", "<A-T>", ":tabnew term://zsh<CR>i")
|
||||
m.keymap("t", "<Esc>", "<C-\\><C-n>")
|
||||
|
||||
-- Use space for folding/unfolding sections
|
||||
m.keymap("n", "<space>", "za")
|
||||
m.keymap("v", "<space>", "zf")
|
||||
|
||||
-- Use shift to quickly move 10 lines up/down
|
||||
m.keymap("n", "K", "10k")
|
||||
m.keymap("n", "J", "10j")
|
||||
|
||||
-- Enable/Disable auto commenting
|
||||
m.keymap("n", "<leader>c", ":setlocal formatoptions-=cro<CR>")
|
||||
m.keymap("n", "<leader>C", ":setlocal formatoptions+=cro<CR>")
|
||||
|
||||
-- Don't leave visual mode after indenting
|
||||
m.keymap("v", "<", "<gv")
|
||||
m.keymap("v", ">", ">gv")
|
||||
|
||||
-- System clipboard copying
|
||||
m.keymap("v", "<C-c>", '"+y')
|
||||
|
||||
-- Alias replace all
|
||||
m.keymap("n", "<A-s>", ":%s//gI<Left><Left><Left>", {silent=false})
|
||||
|
||||
-- Stop search highlight with Esc
|
||||
m.keymap("n", "<esc>", ":noh<CR>")
|
||||
|
||||
-- Start spell-check
|
||||
m.keymap("n", "<leader>s", ":setlocal spell! spelllang=en_us<CR>")
|
||||
|
||||
-- Run shell check
|
||||
m.keymap("n", "<leader>p", ":!shellckeck %<CR>")
|
||||
|
||||
-- Compile opened file (using custom script)
|
||||
m.keymap("n", "<A-c>", ":w | !comp <c-r>%<CR>")
|
||||
|
||||
-- Close all opened buffers
|
||||
m.keymap("n", "<leader>Q", ":bufdo bdelete<CR>")
|
||||
|
||||
-- Don't set the incredibely annoying mappings that trigger dynamic SQL
|
||||
-- completion with dbext and keeps on freezing vim whenever pressed with
|
||||
-- a message saying that dbext plugin isn't installed
|
||||
-- See :h ft-sql.txt
|
||||
vim.g.omni_sql_no_default_maps = 1
|
47
home/.config/nvim/lua/core/options.lua
Normal file
47
home/.config/nvim/lua/core/options.lua
Normal file
|
@ -0,0 +1,47 @@
|
|||
local vim = require("vim")
|
||||
local cmd = vim.cmd
|
||||
local o = vim.opt
|
||||
|
||||
cmd[[filetype plugin on]]
|
||||
|
||||
-- Tab/Indent settings
|
||||
o.autoindent = true -- Enable autoindent
|
||||
o.expandtab = true -- Expand tabs to spaces
|
||||
o.tabstop = 4 -- Tab size in spaces
|
||||
o.shiftwidth = 4 -- Indentation size
|
||||
o.softtabstop = 4 -- Tabs/Spaces interlop
|
||||
o.tabpagemax = 50 -- More tabs
|
||||
o.shiftround = true -- Always round indent to multiple of shiftwidth
|
||||
|
||||
-- Folding
|
||||
o.foldmethod = "indent" -- Use indent to determine the fold levels
|
||||
o.foldnestmax = 8 -- Only fold up to given amount of levels
|
||||
o.foldlevel = 2 -- Set initial fold level
|
||||
o.foldenable = false -- Hide all folds by default
|
||||
|
||||
-- Split order
|
||||
o.splitbelow = true -- Put new windows below current
|
||||
o.splitright = true -- Put new vertical splits to right
|
||||
|
||||
-- In-file search (/)
|
||||
o.ignorecase = true -- Use case insensitive matching
|
||||
o.incsearch = true -- Show partial matches while typing
|
||||
o.hlsearch = true -- Highlight search matches
|
||||
|
||||
-- Show whitespace
|
||||
o.list = true -- Enable showing characters like <Tab>, <EOL>, ...
|
||||
o.listchars = {tab = " ", trail = "·"} -- Specify which characters to show
|
||||
|
||||
-- Command-mode search
|
||||
o.wildmode = {"longest", "list", "full"} -- Enable autocompletion
|
||||
o.wildmenu = true -- Display all matching files when we tab complete
|
||||
table.insert(o.path, "**") -- Search down into subfolders with tab completion
|
||||
|
||||
-- Files
|
||||
o.encoding = "utf-8" -- Use UTF-8 encoding
|
||||
o.autoread = true -- Automatically reload files on change
|
||||
|
||||
-- Misc
|
||||
o.mouse = "a" -- Enable mouse mode
|
||||
o.undolevels = 999 -- Lots of these
|
||||
o.history = 1000 -- More history
|
39
home/.config/nvim/lua/core/theme.lua
Normal file
39
home/.config/nvim/lua/core/theme.lua
Normal file
|
@ -0,0 +1,39 @@
|
|||
local vim = require("vim")
|
||||
local cmd = vim.cmd
|
||||
local g = vim.g
|
||||
local o = vim.opt
|
||||
|
||||
cmd[[syntax on]] -- Turn on syntax highlighting
|
||||
|
||||
o.cursorline = true -- Highlight cursor line
|
||||
o.laststatus = 2 -- Always show status line
|
||||
o.number = true -- Show line numbers
|
||||
o.relativenumber = true -- Use relative line numbers
|
||||
o.showmatch = true -- Show matching bracket
|
||||
o.scrolloff = 5 -- Keep 5 lines horizontal scrolloff
|
||||
o.sidescrolloff = 5 -- Keep 5 chars vertical scrolloff
|
||||
o.showmode = false -- Don't display mode (it's on status line anyway)
|
||||
|
||||
-- I wasn't able to find a way to set guioptions directly in lua
|
||||
cmd[[
|
||||
set guioptions-=m " Remove menubar
|
||||
set guioptions-=T " Remove toolbar
|
||||
set guioptions-=r " Remove right-hand scrollbar
|
||||
set guioptions-=L " Remove left-hand scrollbar
|
||||
]]
|
||||
|
||||
-- Override some colorscheme colors
|
||||
-- * Use more noticable cursor line color
|
||||
cmd[[
|
||||
augroup coloroverride
|
||||
autocmd!
|
||||
autocmd ColorScheme * highlight CursorLine guibg=#2b2b2b
|
||||
autocmd ColorScheme * highlight CursorLineNr guifg=#1F85DE ctermfg=LightBlue
|
||||
augroup END
|
||||
]]
|
||||
|
||||
-- Don't use true colors in TTY
|
||||
o.termguicolors = os.getenv("DISPLAY") and true or false
|
||||
|
||||
-- Use proper syntax highlighting in fenced codeblocks
|
||||
g.markdown_fenced_languages = {"html", "javascript", "typescript", "css", "scss", "lua", "vim", "python"}
|
Loading…
Add table
Add a link
Reference in a new issue