This commit is contained in:
sankalp committed 2024-08-22 07:38:23 +05:45
1 parent a13ea6d3a9
commit 6224efd4a8
30 files changed
+2144 -3784

No files matched your search

+88 -144
View File
@@ -1,161 +1,105 @@
local function augroup(name)
return vim.api.nvim_create_augroup('nvim2k_' .. name, { clear = true })
return vim.api.nvim_create_augroup("nvim" .. name, { clear = true })
end
-- don't auto comment new line
vim.api.nvim_create_autocmd('BufEnter', { command = [[set formatoptions-=cro]] })
-- to make border as same as neovim ColorScheme
vim.api.nvim_create_autocmd({ 'UIEnter', 'ColorScheme' }, {
callback = function()
local normal = vim.api.nvim_get_hl(0, { name = 'Normal' })
if not normal.bg then
return
end
io.write(string.format('\027Ptmux;\027\027]11;#%06x\007\027\\', normal.bg))
io.write(string.format('\027]11;#%06x\027\\', normal.bg))
end,
})
vim.api.nvim_create_autocmd('UILeave', {
callback = function()
io.write('\027Ptmux;\027\027]111;\007\027\\')
io.write('\027]111\027\\')
end,
})
-- Highlight on yank
vim.api.nvim_create_autocmd('TextYankPost', {
group = augroup('highlight_yank'),
callback = function()
vim.highlight.on_yank()
end,
})
-- go to last loc when opening a buffer
-- this mean that when you open a file, you will be at the last position
vim.api.nvim_create_autocmd('BufReadPost', {
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local lcount = vim.api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
})
-- auto close brackets
vim.api.nvim_create_autocmd('FileType', { pattern = 'man', command = [[nnoremap <buffer><silent> q :quit<CR>]] })
-- show cursor line only in active window
local cursorGrp = vim.api.nvim_create_augroup('CursorLine', { clear = true })
vim.api.nvim_create_autocmd({ 'InsertLeave', 'WinEnter' }, {
pattern = '*',
command = 'set cursorline',
group = cursorGrp,
})
vim.api.nvim_create_autocmd(
{ 'InsertEnter', 'WinLeave' },
{ pattern = '*', command = 'set nocursorline', group = cursorGrp }
)
-- Enable spell checking for certain file types
vim.api.nvim_create_autocmd(
{ 'BufRead', 'BufNewFile' },
-- { pattern = { "*.txt", "*.md", "*.tex" }, command = [[setlocal spell<cr> setlocal spelllang=en,de<cr>]] }
{
pattern = { '*.txt', '*.md', '*.tex' },
callback = function()
vim.opt.spell = true
vim.opt.spelllang = 'en,de'
end,
}
)
-- go to last loc when opening a buffer
vim.api.nvim_create_autocmd('BufReadPost', {
group = augroup('last_loc'),
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local lcount = vim.api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
})
-- Strip trailing spaces before write
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
group = augroup('strip_space'),
pattern = { '*' },
callback = function()
vim.cmd([[ %s/\s\+$//e ]])
end,
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
group = augroup("strip_space"),
pattern = { "*" },
callback = function()
vim.cmd([[ %s/\s\+$//e ]])
end,
})
-- Check if we need to reload the file when it changed
vim.api.nvim_create_autocmd({ 'FocusGained', 'TermClose', 'TermLeave' }, {
group = augroup('checktime'),
command = 'checktime',
vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, {
group = augroup("checktime"),
command = "checktime",
})
-- Highlight on yank
vim.api.nvim_create_autocmd("TextYankPost", {
group = augroup("highlight_yank"),
callback = function()
vim.highlight.on_yank()
end,
})
-- resize splits if window got resized
vim.api.nvim_create_autocmd({ 'VimResized' }, {
group = augroup('resize_splits'),
callback = function()
vim.cmd('tabdo wincmd =')
end,
vim.api.nvim_create_autocmd({ "VimResized" }, {
group = augroup("resize_splits"),
callback = function()
vim.cmd("tabdo wincmd =")
end,
})
-- wrap and check for spell in text filetypes
vim.api.nvim_create_autocmd('FileType', {
group = augroup('wrap_spell'),
pattern = { 'gitcommit', 'markdown' },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
end,
})
-- Auto create dir when saving a file, in case some intermediate directory does not exist
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
group = augroup('auto_create_dir'),
callback = function(event)
local file = vim.loop.fs_realpath(event.match) or event.match
vim.fn.mkdir(vim.fn.fnamemodify(file, ':p:h'), 'p')
end,
})
-- Set arb filetype
vim.api.nvim_create_autocmd({ 'BufEnter' }, {
group = augroup('set_file_type'),
pattern = { '*.arb' },
command = require('core.util').get_file_type_cmd('arb'),
-- go to last loc when opening a buffer
vim.api.nvim_create_autocmd("BufReadPost", {
group = augroup("last_loc"),
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local lcount = vim.api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
})
-- close some filetypes with <q>
vim.api.nvim_create_autocmd('FileType', {
group = vim.api.nvim_create_augroup('close_with_q', { clear = true }),
pattern = {
'PlenaryTestPopup',
'help',
'lspinfo',
'man',
'notify',
'qf',
'spectre_panel',
'startuptime',
'tsplayground',
'neotest-output',
'checkhealth',
'neotest-summary',
'neotest-output-panel',
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set('n', 'q', '<cmd>close<cr>', { buffer = event.buf, silent = true })
end,
vim.api.nvim_create_autocmd("FileType", {
group = augroup("close_with_q"),
pattern = {
"DressingSelect",
"Jaq",
"PlenaryTestPopup",
"fugitive",
"help",
"lir",
"lspinfo",
"man",
"notify",
"qf",
"spectre_panel",
"startuptime",
"tsplayground",
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
end,
})
-- resize neovim split when terminal is resized
vim.api.nvim_command('autocmd VimResized * wincmd =')
-- wrap and check for spell in text filetypes
vim.api.nvim_create_autocmd("FileType", {
group = augroup("wrap_spell"),
pattern = { "gitcommit", "markdown" },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
end,
})
-- Auto create dir when saving a file, in case some intermediate directory does not exist
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
group = augroup("auto_create_dir"),
callback = function(event)
local file = vim.loop.fs_realpath(event.match) or event.match
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
end,
})
-- Set arb filetype
vim.api.nvim_create_autocmd({ "BufEnter" }, {
group = augroup("set_file_type"),
pattern = { "*.arb" },
command = require("lib.util").get_file_type_cmd("arb"),
})
-- Disable format options
vim.api.nvim_create_autocmd("FileType", {
group = augroup("disable_formatoptions"),
pattern = "*",
callback = function()
vim.opt_local.formatoptions:remove({ "c", "r", "o" })
end,
})
+1 -1
View File
@@ -30,7 +30,7 @@ end, {})
-- Switch to git root or file parent dir
vim.api.nvim_create_user_command('RootDir', function()
local root = require('core.util').get_root_dir()
local root = require('lib.util').get_root_dir()
if root == '' then
return
-75
View File
@@ -1,75 +0,0 @@
local function map(mode, lhs, rhs, opts)
opts = opts or {}
opts.silent = opts.silent ~= false
vim.keymap.set(mode, lhs, rhs, opts)
end
local opts = { noremap = true, silent = true }
-- Use jj as escape
map('i', 'jj', '<Esc>', opts)
map('t', 'JJ', '<C-\\><C-n>', opts)
-- Visual overwrite paste
map({ 'v', 'x' }, 'p', '"_dP', opts)
-- Do not copy on x
map({ 'v', 'x' }, 'x', '"_x', opts)
-- Increment/decrement
map({ 'n', 'v', 'x' }, '-', '<C-x>', opts)
map({ 'n', 'v', 'x' }, '=', '<C-a>', opts)
-- Move to line beginning and end
map({ 'n', 'v', 'x' }, 'gl', '$', { desc = 'End of line' })
map({ 'n', 'v', 'x' }, 'gh', '^', { desc = 'Beginning of line' })
-- Select all
map('n', '<C-a>', 'gg<S-v>G')
-- Deleting without yanking empty line
map('n', 'dd', function()
local is_empty_line = vim.api.nvim_get_current_line():match('^%s*$')
if is_empty_line then
return '"_dd'
else
return 'dd'
end
end, { noremap = true, expr = true, desc = "Don't Yank Empty Line to Clipboard" })
-- Center Cursors
map('n', 'J', 'mzJ`z', opts)
map('n', '<C-d>', '<C-d>zz', opts)
map('n', '<C-u>', '<C-u>zz', opts)
map('n', 'n', 'nzzzv', opts)
map('n', 'N', 'Nzzzv', opts)
-- Better up/down
map('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
map('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
-- Move text up and down
map({ 'v', 'x' }, 'J', ":move '>+1<CR>gv-gv", opts)
map({ 'v', 'x' }, 'K', ":move '<-2<CR>gv-gv", opts)
-- Clear search, diff update and redraw
map({ 'i', 'n' }, '<esc>', '<cmd>noh<cr><esc>', { desc = 'Escape and clear hlsearch' })
-- Consistent n/N search navigation
map('n', 'n', "'Nn'[v:searchforward]", { expr = true, desc = 'Next search result' })
map('x', 'n', "'Nn'[v:searchforward]", { expr = true, desc = 'Next search result' })
map('o', 'n', "'Nn'[v:searchforward]", { expr = true, desc = 'Next search result' })
map('n', 'N', "'nN'[v:searchforward]", { expr = true, desc = 'Prev search result' })
map('x', 'N', "'nN'[v:searchforward]", { expr = true, desc = 'Prev search result' })
map('o', 'N', "'nN'[v:searchforward]", { expr = true, desc = 'Prev search result' })
-- Better indenting
map('v', '<', '<gv')
map('v', '>', '>gv')
-- Add undo breakpoints
map('i', ',', ',<c-g>u')
map('i', '.', '.<c-g>u')
map('i', ';', ';<c-g>u')
map({ 'i' }, '<C-l>', '<Right>', { desc = 'Move cursor to right' })
map({ 'i' }, '<C-h>', '<Left>', { desc = 'Move cursor to right' })
+72
View File
@@ -0,0 +1,72 @@
local function map(mode, lhs, rhs, opts)
opts = opts or {}
opts.silent = opts.silent ~= false
vim.keymap.set(mode, lhs, rhs, opts)
end
local opts = { noremap = true, silent = true }
-- Use jj as escape
map("i", "jj", "<Esc>", opts)
map("t", "JJ", "<C-\\><C-n>", opts)
-- Visual overwrite paste
map({ "v", "x" }, "p", '"_dP', opts)
-- Do not copy on x
map({ "v", "x" }, "x", '"_x', opts)
-- Increment/decrement
map({ "n", "v", "x" }, "-", "<C-x>", opts)
map({ "n", "v", "x" }, "=", "<C-a>", opts)
-- Move to line beginning and end
map({ "n", "v", "x" }, "gl", "$", { desc = "End of line" })
map({ "n", "v", "x" }, "gh", "^", { desc = "Beginning of line" })
-- Select all
map("n", "<C-a>", "gg<S-v>G")
map("n", "<C-s>", "<CMD>up<CR>", { desc = "Save File" })
-- Center Cursors
map("n", "J", "mzJ`z", opts)
map("n", "<C-d>", "<C-d>zz", opts)
map("n", "<C-u>", "<C-u>zz", opts)
map("n", "n", "nzzzv", opts)
map("n", "N", "Nzzzv", opts)
-- Better up/down
map("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
map("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
-- Move text up and down
map({ "v", "x" }, "J", ":move '>+1<CR>gv-gv", opts)
map({ "v", "x" }, "K", ":move '<-2<CR>gv-gv", opts)
-- Clear search, diff update and redraw
map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", { desc = "Escape and clear hlsearch" })
-- Consistent n/N search navigation
map("n", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" })
map("x", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" })
map("o", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" })
map("n", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
map("x", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
map("o", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
-- Better indenting
map("v", "<", "<gv")
map("v", ">", ">gv")
-- Add undo breakpoints
map("i", ",", ",<c-g>u")
map("i", ".", ".<c-g>u")
map("i", ";", ";<c-g>u")
map({ "i" }, "<C-l>", "<Right>", { desc = "Move cursor to right" })
map({ "i" }, "<C-h>", "<Left>", { desc = "Move cursor to right" })
map("n", "d", '"_d', { desc = "Delete without replacing clipboad" })
map("n", "x", '"_x', { desc = "Cut without replacing clipboad" })
map("n", "c", '"_c', { desc = "Change without replacing clipboad" })
map("v", "p", '"_dP', { desc = "Paste without replacing clipboard" })
+94 -81
View File
@@ -1,95 +1,108 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
---@diagnostic disable-next-line: undefined-field
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
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'--single-branch',
'https://github.com/folke/lazy.nvim.git',
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
vim.opt.runtimepath:prepend(lazypath)
require('lazy').setup({
spec = {
{ import = 'plugins' },
},
install = {
missing = true,
colorscheme = { 'moonfly' },
},
checker = {
enabled = true,
notify = false,
},
change_detection = {
enabled = true,
notify = false,
},
ui = {
icons = {
cmd = '',
config = '',
event = '',
ft = '',
init = '',
import = '',
keys = '',
lazy = '󰒲 ',
loaded = '●',
not_loaded = '○',
plugin = '',
runtime = '',
require = '󰢱 ',
source = '',
start = '',
task = '✔ ',
list = {
'●',
'➜',
'★',
'‒',
},
},
},
local status_ok, lazy = pcall(require, 'lazy')
if not status_ok then
return
end
local icons = require('lib.icons')
lazy.setup({
root = vim.fn.stdpath('data') .. '/lazy',
defaults = { lazy = true },
spec = 'plugins',
lockfile = vim.fn.stdpath('config') .. '/lua/lock.json',
concurrency = 8,
dev = { path = '~/Projects/GitHub/', patterns = {}, fallback = false },
install = { missing = true, colorscheme = { 'onedark' } },
git = {
log = { '--since=3 days ago' },
timeout = 120,
url_format = 'https://github.com/%s.git',
filter = true,
},
ui = {
size = { width = 0.9, height = 0.8 },
wrap = true,
border = 'rounded',
icons = {
cmd = icons.ui.Terminal,
config = icons.ui.Gear,
event = icons.ui.Electric,
ft = icons.documents.File,
init = icons.ui.Rocket,
import = icons.documents.Import,
keys = icons.ui.Keyboard,
lazy = icons.ui.Sleep,
loaded = icons.ui.CircleSmall,
not_loaded = icons.ui.CircleSmallEmpty,
plugin = icons.ui.Package,
runtime = icons.ui.Neovim,
source = icons.ui.Code,
start = icons.ui.Play,
task = icons.ui.Check,
list = {
icons.ui.CircleSmall,
icons.ui.Arrow,
icons.ui.Star,
icons.ui.Minus,
},
},
browser = nil,
throttle = 20,
custom_keys = {
['<localleader>l'] = function(plugin)
require('lazy.util').float_term({ 'lazygit', 'log' }, {
cwd = plugin.dir,
})
end,
['<localleader>t'] = function(plugin)
require('lazy.util').float_term(nil, {
cwd = plugin.dir,
})
end,
},
},
diff = { cmd = 'git' },
checker = { enabled = false, concurrency = nil, notify = true, frequency = 3600 },
change_detection = { enabled = true, notify = true },
performance = {
cache = { enabled = true },
reset_packpath = true,
rtp = {
reset = true,
paths = {},
disabled_plugins = {
'2html_plugin',
'tohtml',
'getscript',
'getscriptPlugin',
'gzip',
'logipat',
'netrw',
'netrwPlugin',
'netrwSettings',
'netrwFileHandlers',
'matchit',
'tar',
'tarPlugin',
'rrhelper',
'spellfile_plugin',
'vimball',
'vimballPlugin',
'zip',
'zipPlugin',
'tutor',
'rplugin',
'syntax',
'synmenu',
'optwin',
'compiler',
'bugreport',
'ftplugin',
'tohtml',
-- 'tutor',
-- 'matchit',
-- 'matchparen',
-- 'netrwPlugin',
},
},
},
readme = {
root = vim.fn.stdpath('state') .. '/lazy/readme',
files = { 'README.md', 'lua/**/README.md' },
skip_if_doc_exists = true,
},
state = vim.fn.stdpath('state') .. '/lazy/state.json',
})
+88 -55
View File
@@ -1,59 +1,92 @@
--Remap space as leader key
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.opt.backup = false -- creates a backup file
vim.opt.clipboard = 'unnamedplus' -- allows neovim to access the system clipboard
vim.opt.cmdheight = 0 -- more space in the neovim command line for displaying messages
vim.opt.completeopt = { 'menuone', 'noselect' } -- mostly just for cmp
vim.opt.conceallevel = 0 -- so that `` is visible in markdown files
-- vim.opt.fileencoding = "utf-8" -- the encoding written to a file
vim.opt.hlsearch = true -- highlight all matches on previous search pattern
vim.opt.ignorecase = true -- ignore case in search patterns
vim.opt.mouse = 'a' -- allow the mouse to be used in neovim
vim.opt.pumheight = 10 -- pop up menu height
vim.opt.pumblend = 10
vim.opt.showmode = false -- we don't need to see things like -- INSERT -- anymore
vim.opt.showtabline = 2 -- always show tabs
vim.opt.smartcase = true -- smart case
vim.opt.smartindent = true -- make indenting smarter again
vim.opt.splitbelow = true -- force all horizontal splits to go below current window
vim.opt.splitright = true -- force all vertical splits to go to the right of current window
vim.opt.swapfile = false -- creates a swapfile
vim.opt.termguicolors = true -- set term gui colors (most terminals support this)
vim.opt.timeoutlen = 1000 -- time to wait for a mapped sequence to complete (in milliseconds)
vim.opt.undofile = true -- enable persistent undo
vim.opt.updatetime = 100 -- faster completion (4000ms default)
vim.opt.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
vim.opt.expandtab = true -- convert tabs to spaces
vim.opt.shiftwidth = 2 -- the number of spaces inserted for each indentation
vim.opt.tabstop = 2 -- insert 2 spaces for a tab
vim.opt.cursorline = false -- highlight the current line
vim.opt.cursorlineopt = 'number'
vim.opt.number = true -- set numbered lines
vim.opt.laststatus = 0 --disable native statusline
vim.opt.showcmd = false
vim.opt.ruler = false
vim.opt.relativenumber = true -- set relative numbered lines
vim.opt.numberwidth = 4 -- set number column width to 2 {default 4}
vim.opt.signcolumn = 'yes' -- always show the sign column, otherwise it would shift the text each time
vim.opt.wrap = false -- display lines as one long line
vim.opt.scrolloff = 0
vim.opt.sidescrolloff = 8
vim.opt.guifont = 'monospace:h17' -- the font used in graphical neovim applications
vim.opt.title = true
vim.opt.titlelen = 0 -- do not shorten title
vim.opt.inccommand = 'split' -- split below for to show replaces
vim.opt.virtualedit = 'block'
vim.opt.fillchars = vim.opt.fillchars + 'eob: '
vim.opt.fillchars:append({
stl = ' ',
})
local options = {
ai = true,
autoindent = true,
autowrite = true,
backspace = "indent,eol,start",
backup = false, -- creates a backup file
breakindent = true,
clipboard = "unnamedplus", -- allows neovim to access the system clipboard
cmdheight = 1, -- more space in the neovim command line for displaying messages
completeopt = "menu,menuone,noselect", -- mostly just for cmp
conceallevel = 0, -- so that `` is visible in markdown files
confirm = true, -- Confirm to save changes before exiting modified buffer
cursorline = true, -- highlight the current line
expandtab = true, -- convert tabs to spaces
fileencoding = "utf-8", -- the encoding written to a file
formatoptions = "jlnqt", -- set formatoptions, check help fo-table
grepformat = "%f:%l:%c:%m",
grepprg = "rg --vimgrep",
hlsearch = true, -- highlight all matches on previous search pattern
ignorecase = true, -- ignore case in search patterns
inccommand = "split", -- preview incremental substitute
laststatus = 3,
list = false,
-- listchars = { trail = "", tab = "", nbsp = "_", extends = ">", precedes = "<" }, -- highlight
mouse = "a", -- allow the mouse to be used in neovim
number = true, -- set numbered lines
numberwidth = 4, -- set number column width to 3 {default 4}
pumblend = 10, -- Popup blen
pumheight = 10, -- pop up menu height
relativenumber = true, -- set relative numbered lines
scrolloff = 10, -- is one of my fav
sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal",
shiftround = true, -- Round indent
shiftwidth = 4, -- the number of spaces inserted for each indentation
showcmd = false,
showmode = false, -- we don't need to see things like -- INSERT -- anymore
showtabline = 0, -- always show tabs
si = true,
sidescrolloff = 8,
signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time
smartcase = true, -- smart case
smartindent = true, -- make indenting smarter again
smarttab = true,
splitbelow = true, -- force all horizontal splits to go below current window
splitright = true, -- force all vertical splits to go to the right of current window
swapfile = false, -- creates a swapfile
tabstop = 4, -- insert 2 spaces for a tab
termguicolors = true, -- set term gui colors (most terminals support this)
timeoutlen = 300, -- time to wait for a mapped sequence to complete (in milliseconds)
undofile = true, -- enable persistent undo
undolevels = 10000,
updatetime = 50, -- faster completion (4000ms default)
wildmenu = true, -- wildmenu
wildmode = "longest:full,full", -- Command-line completion mode
winminwidth = 5, -- Minimum window width
wrap = false, -- display lines as one long line
writebackup = false, -- do not edit backups
}
vim.opt.shortmess:append('c')
vim.cmd('set whichwrap+=<,>,[,],h,l')
vim.cmd([[set iskeyword+=-]])
for k, v in pairs(options) do
vim.opt[k] = v
end
-- netrw file explorer settings
vim.g.netrw_winsize = 20
vim.g.netrw_banner = 0
vim.g.netrw_mouse = 2
vim.g.netrw_liststyle = 1
-- Fix markdown indentation settings
vim.g.markdown_recommended_style = 0
vim.opt.path:append({ "**" })
vim.opt.shortmess:append({ W = true, I = true, c = true })
-- hides `~` at the end of the buffer
vim.cmd([[set fillchars+=eob:\ ]])
vim.cmd([[
setlocal spell spelllang=en "Set spellcheck language to en
setlocal spell! "Disable spell checks by default
filetype plugin indent on
if has('win32')
let g:python3_host_prog = $HOME . '/scoop/apps/python/current/python.exe'
endif
let &t_Cs = "\e[4:3m" "Undercurl
let &t_Ce = "\e[4:0m"
set whichwrap+=<,>,[,],h,l
set iskeyword+=-
]])
-66
View File
@@ -1,66 +0,0 @@
local util = {}
util.get_user_config = function(key, default)
local status_ok, user = pcall(require, 'user')
if not status_ok then
return default
end
local user_config = user[key]
if user_config == nil then
return default
end
return user_config
end
util.get_root_dir = function()
local bufname = vim.fn.expand('%:p')
if vim.fn.filereadable(bufname) == 0 then
return
end
local parent = vim.fn.fnamemodify(bufname, ':h')
local git_root = vim.fn.systemlist('git -C ' .. parent .. ' rev-parse --show-toplevel')
if #git_root > 0 and git_root[1] ~= '' then
return git_root[1]
else
return parent
end
end
util.get_file_type_cmd = function(extension)
local root = util.get_root_dir()
if extension == 'arb' and root then
local gemfile_exists = vim.fn.filereadable(root .. '/Gemfile') == 1
local pubspec_exists = vim.fn.filereadable(root .. '/pubspec.yaml') == 1
if gemfile_exists then
return 'setfiletype ruby'
end
if pubspec_exists then
return 'setfiletype json'
end
end
return ''
end
util.is_present = function(bin)
return vim.fn.executable(bin) == 1
end
util.telescope_select = function(options, options_desc, select_prompt)
require('telescope.pickers')
.new({}, {
prompt_title = select_prompt,
results_title = options_desc,
finder = require('telescope.finders').new_table({
results = options,
entry_maker = require('telescope.make_entry').gen_from_file(),
}),
sorter = require('telescope.sorters').get_fzy_sorter(),
previewer = require('telescope.previewers').vim_buffer_cat.new({}),
})
:find()
end
return util