From 95660c65afdf3054458e6c07d51c8f85ae770b0f Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Sat, 30 Oct 2021 02:33:38 +0300 Subject: [PATCH] feat: transfer options and bindings --- .gitignore | 1 + init.lua | 14 ++++++ lua/bindings.lua | 18 +++++++ lua/options.lua | 95 ++++++++++++++++++++++++++++++++++++ plugin/packer-compiled.lua | 98 -------------------------------------- 5 files changed, 128 insertions(+), 98 deletions(-) create mode 100644 .gitignore create mode 100644 lua/bindings.lua delete mode 100644 plugin/packer-compiled.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8bff6c2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +plugin/packer-compiled.lua diff --git a/init.lua b/init.lua index 6ac22b4..dcb21d8 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,5 @@ local g = vim.g +local cmd = vim.cmd -- Allow loading */init.lua files package.path = "./?/init.lua;"..package.path @@ -7,7 +8,20 @@ package.path = "./?/init.lua;"..package.path g.mapleader = [[ ]] g.maplocalleader = [[,]] +-- Disable some built-in plugins we don't want +local disabled_built_ins = { + 'matchit', + 'netrw', + 'netrwPlugin', +} + +for _, name in ipairs(disabled_built_ins) do + g['loaded_' .. name] = 1 +end + require("impatient") require("plugins") +require("options") +require("bindings") diff --git a/lua/bindings.lua b/lua/bindings.lua new file mode 100644 index 0000000..d67bb19 --- /dev/null +++ b/lua/bindings.lua @@ -0,0 +1,18 @@ +local map = require 'utils.map' + +local silent = {silent = true} + +-- Window movement +map('n', '', 'h') +map('n', '', 'j') +map('n', '', 'k') +map('n', '', 'l') + + +-- Toggle whitespace characters +map('n', 'tw', ':setlocal list!') + + +-- Toggle numbers and sign column +map('n', 'tn', ':setlocal relativenumber!:setlocal number!') + diff --git a/lua/options.lua b/lua/options.lua index e69de29..4a9293e 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -0,0 +1,95 @@ +local opt = require 'utils.opt' +local o, wo, bo = vim.o, vim.wo, vim.bo +local cmd = vim.cmd + +cmd [[syntax on]] +cmd [[filetype plugin on]] + + +local buffer = { o, bo } +local window = { o, wo } + +-- Don't wrap text to next line if there isin't enough space +opt('wrap', false) + +-- Highlight current line +opt('cursorline', true, window) + +-- Store less in shada files +opt('shada', [['20,<50,s10,h,/100]]) + +-- Show current mode that you are in +opt('showmode', false) + +-- Keep non-visible files open +opt('hidden', true) + +-- Skip redrawing window while executing macro +opt('lazyredraw', true) + +-- Always use system clipboard +opt('clipboard', 'unnamedplus') + +-- Amount of time after which while typing mapping will be canceled +opt('timeoutlen', 300) + +-- Load external project specific configs +opt('exrc', true) +opt('secure', true) + +-- How whitespace characters should be displayed +opt('listchars', [[space:.,eol:$,tab:>-]]) + +-- If possible use 24 Bit Colors +if vim.fn.has('termguicolors') == 1 then + opt('termguicolors', true) +end + +-- Better Searching (Incremental searching, live replacing) +opt('hlsearch', false) +opt('incsearch', true) +opt('inccommand', 'nosplit') + +-- Always keep at least 8 blank lines below the last line +opt('scrolloff', 8) + +-- Draw a line on the 80 character mark for reference +-- My laptop screen is pretty small so it's 80 so that 2 splits can fit +-- If you have a wider monitor go ahead and use 100 or 120. +opt('colorcolumn', '80') + +-- Break lines +-- opt('textwidth', 80) + +-- Display relative and absolute line numbers +opt('number', true, window) +opt('relativenumber', true, window) + +-- Recovery +opt('undofile', true, buffer) + +-- Mouse support +opt('mouse', 'nivh') + +-- Auto sign column +opt('signcolumn', 'auto:1', window) + +-- Disable those annoying DINGS when you pressing something too much +opt('errorbells', false) + +-- Always use system clipboard +opt('clipboard', 'unnamedplus') + +-- Identation/Tab settings +local tab_size = 2 +opt('foldmethod', 'indent', window) +opt('expandtab', false, buffer) +opt('smartindent', true, buffer) +opt('shiftwidth', tab_size, buffer) +opt('tabstop', tab_size, buffer) +opt('softtabstop', tab_size, buffer) + +-- Place splits below and to the right by default +opt('splitbelow', true) +opt('splitright', true) + diff --git a/plugin/packer-compiled.lua b/plugin/packer-compiled.lua deleted file mode 100644 index cb4d4c8..0000000 --- a/plugin/packer-compiled.lua +++ /dev/null @@ -1,98 +0,0 @@ --- Automatically generated packer.nvim plugin loader code - -if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then - vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"') - return -end - -vim.api.nvim_command('packadd packer.nvim') - -local no_errors, error_msg = pcall(function() - - local time - local profile_info - local should_profile = false - if should_profile then - local hrtime = vim.loop.hrtime - profile_info = {} - time = function(chunk, start) - if start then - profile_info[chunk] = hrtime() - else - profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 - end - end - else - time = function(chunk, start) end - end - -local function save_profiles(threshold) - local sorted_times = {} - for chunk_name, time_taken in pairs(profile_info) do - sorted_times[#sorted_times + 1] = {chunk_name, time_taken} - end - table.sort(sorted_times, function(a, b) return a[2] > b[2] end) - local results = {} - for i, elem in ipairs(sorted_times) do - if not threshold or threshold and elem[2] > threshold then - results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' - end - end - - _G._packer = _G._packer or {} - _G._packer.profile_output = results -end - -time([[Luarocks path setup]], true) -local package_path_str = "/home/puzonas/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/puzonas/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/puzonas/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/puzonas/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" -local install_cpath_pattern = "/home/puzonas/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so" -if not string.find(package.path, package_path_str, 1, true) then - package.path = package.path .. ';' .. package_path_str -end - -if not string.find(package.cpath, install_cpath_pattern, 1, true) then - package.cpath = package.cpath .. ';' .. install_cpath_pattern -end - -time([[Luarocks path setup]], false) -time([[try_loadstring definition]], true) -local function try_loadstring(s, component, name) - local success, result = pcall(loadstring(s)) - if not success then - vim.schedule(function() - vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) - end) - end - return result -end - -time([[try_loadstring definition]], false) -time([[Defining packer_plugins]], true) -_G.packer_plugins = { - ["impatient.nvim"] = { - loaded = true, - path = "/home/puzonas/.local/share/nvim/site/pack/packer/start/impatient.nvim" - }, - ["packer.nvim"] = { - loaded = true, - path = "/home/puzonas/.local/share/nvim/site/pack/packer/start/packer.nvim" - }, - ["vim-fugitive"] = { - config = { "require 'config.fugitive'" }, - loaded = true, - path = "/home/puzonas/.local/share/nvim/site/pack/packer/start/vim-fugitive" - } -} - -time([[Defining packer_plugins]], false) --- Config for: vim-fugitive -time([[Config for vim-fugitive]], true) -require 'config.fugitive' -time([[Config for vim-fugitive]], false) -if should_profile then save_profiles() end - -end) - -if not no_errors then - vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') -end