update config
This commit is contained in:
parent
85b431d6f9
commit
fc922961fe
1
init.lua
1
init.lua
@ -1,4 +1,3 @@
|
||||
local opt = require 'utils.opt'
|
||||
local g = vim.g
|
||||
local cmd = vim.cmd
|
||||
|
||||
|
@ -31,13 +31,6 @@ map('v', '>', '>gv')
|
||||
map('n', '<C-Left>', ':tabprevious<cr>', silent)
|
||||
map('n', '<C-Right>', ':tabnext<cr>', silent)
|
||||
|
||||
-- Move lines up or down
|
||||
map('n', '<A-j>', ':m .+1<CR>==', silent)
|
||||
map('n', '<A-j>', ':m .+1<CR>==', silent)
|
||||
map('n', '<A-k>', ':m .-2<CR>==', silent)
|
||||
map('v', '<A-j>', ":m '>+1<CR>gv=gv", silent)
|
||||
map('v', '<A-k>', ":m '<-2<CR>gv=gv", silent)
|
||||
|
||||
-- Move between windows easier in terminal windows
|
||||
function _G.set_terminal_keymaps()
|
||||
local opts = {buffer = 0}
|
||||
|
@ -1,5 +1,8 @@
|
||||
local ts = vim.treesitter
|
||||
local query = ts.parse_query("c", "(preproc_function_def value: (preproc_arg) @macro_def)")
|
||||
local query = ts.parse_query("c", [[
|
||||
(preproc_function_def value: (preproc_arg) @macro_def)
|
||||
(preproc_def value: (preproc_arg) @macro_def)
|
||||
]])
|
||||
|
||||
local function get_ast_root(bufnr)
|
||||
local tree = ts.get_parser(bufnr, "c"):parse()
|
||||
|
4
lua/config/based.lua
Normal file
4
lua/config/based.lua
Normal file
@ -0,0 +1,4 @@
|
||||
local based = require("based")
|
||||
based.setup{}
|
||||
|
||||
vim.keymap.set({"n", "v"}, "<C-b>", based.convert)
|
46
lua/config/cellular-automaton.lua
Normal file
46
lua/config/cellular-automaton.lua
Normal file
@ -0,0 +1,46 @@
|
||||
local automaton = require("cellular-automaton")
|
||||
|
||||
local timeout = 120
|
||||
|
||||
local timer
|
||||
local function enable_screensaver()
|
||||
local group = vim.api.nvim_create_augroup('CellularAutomatonScreenSaver', {clear=true})
|
||||
|
||||
local animations = {}
|
||||
for name in pairs(automaton.animations) do
|
||||
table.insert(animations, name)
|
||||
end
|
||||
|
||||
local function play_random_animation()
|
||||
local idx = math.random(#animations)
|
||||
local animation_name = animations[idx]
|
||||
if animation_name then
|
||||
automaton.start_animation(animation_name)
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd({'CursorHold', 'CursorHoldI'}, {
|
||||
group = group,
|
||||
callback = function()
|
||||
-- TODO: Will vim.defer_fn suffice here?
|
||||
timer = vim.loop.new_timer()
|
||||
timer:start(timeout * 1000, 0, vim.schedule_wrap(function()
|
||||
if timer:is_active() then timer:stop() end
|
||||
if not timer:is_closing() then timer:close() end
|
||||
|
||||
play_random_animation()
|
||||
end))
|
||||
|
||||
vim.api.nvim_create_autocmd({'CursorMoved', 'CursorMovedI'}, {
|
||||
group = group,
|
||||
callback = function()
|
||||
if timer:is_active() then timer:stop() end
|
||||
if not timer:is_closing() then timer:close() end
|
||||
end,
|
||||
once = true
|
||||
})
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
enable_screensaver()
|
@ -1,26 +0,0 @@
|
||||
local opt = require 'utils.opt'
|
||||
|
||||
opt('showmode', false)
|
||||
|
||||
vim.cmd [[
|
||||
function! LightlineFilename()
|
||||
let filename = expand('%:t') !=# '' ? expand('%:t') : '[No Name]'
|
||||
let modified = &modified ? ' +' : ''
|
||||
return filename . modified
|
||||
endfunction
|
||||
]]
|
||||
|
||||
vim.g.lightline = {
|
||||
colorscheme = vim.g.colors_name,
|
||||
active = {
|
||||
left = { { 'mode', 'paste' }, { 'gitbranch', 'readonly', 'filename' } }
|
||||
},
|
||||
component_function = {
|
||||
gitbranch = 'FugitiveHead',
|
||||
filename = 'LightlineFilename'
|
||||
},
|
||||
tabline = {
|
||||
right = {}
|
||||
}
|
||||
}
|
||||
|
161
lua/config/lualine.lua
Normal file
161
lua/config/lualine.lua
Normal file
@ -0,0 +1,161 @@
|
||||
local bg = vim.g.srcery_xgray1
|
||||
|
||||
local colors = {
|
||||
red = vim.g.srcery_red,
|
||||
grey = vim.g.srcery_black,
|
||||
black = vim.g.srcery_hard_black,
|
||||
white = vim.g.srcery_bright_white,
|
||||
light_green = vim.g.srcery_bright_green,
|
||||
orange = vim.g.srcery_orange,
|
||||
green = vim.g.srcery_green,
|
||||
}
|
||||
|
||||
local theme = {
|
||||
normal = {
|
||||
a = { fg = colors.white, bg = colors.black },
|
||||
b = { fg = colors.white, bg = colors.grey },
|
||||
c = { fg = colors.black, bg = bg },
|
||||
z = { fg = colors.white, bg = colors.black },
|
||||
},
|
||||
insert = { a = { fg = colors.black, bg = colors.light_green } },
|
||||
visual = { a = { fg = colors.black, bg = colors.orange } },
|
||||
replace = { a = { fg = colors.black, bg = colors.green } },
|
||||
}
|
||||
|
||||
local empty = require('lualine.component'):extend()
|
||||
function empty:draw(default_highlight)
|
||||
self.status = ''
|
||||
self.applied_separator = ''
|
||||
self:apply_highlights(default_highlight)
|
||||
self:apply_section_separators()
|
||||
return self.status
|
||||
end
|
||||
|
||||
-- Put proper separators and gaps between components in sections
|
||||
local function process_sections(sections)
|
||||
for name, section in pairs(sections) do
|
||||
local left = name:sub(9, 10) < 'x'
|
||||
for pos = 1, name ~= 'lualine_z' and #section or #section - 1 do
|
||||
table.insert(section, pos * 2, { empty, color = { fg = bg, bg = bg } })
|
||||
end
|
||||
for id, comp in ipairs(section) do
|
||||
if type(comp) ~= 'table' then
|
||||
comp = { comp }
|
||||
section[id] = comp
|
||||
end
|
||||
comp.separator = left and { right = '' } or { left = '' }
|
||||
end
|
||||
end
|
||||
return sections
|
||||
end
|
||||
|
||||
local function search_result()
|
||||
local last_search = vim.fn.getreg('/')
|
||||
if not last_search or last_search == '' then
|
||||
return ''
|
||||
end
|
||||
local searchcount = vim.fn.searchcount { maxcount = 9999 }
|
||||
if searchcount.total == 0 then
|
||||
return ''
|
||||
end
|
||||
return last_search .. '(' .. searchcount.current .. '/' .. searchcount.total .. ')'
|
||||
end
|
||||
|
||||
local function modified()
|
||||
if vim.bo.modified then
|
||||
return '+'
|
||||
elseif vim.bo.modifiable == false or vim.bo.readonly == true then
|
||||
return '-'
|
||||
end
|
||||
return ''
|
||||
end
|
||||
|
||||
local function recording_macro()
|
||||
local reg = vim.api.nvim_call_function("reg_recording", {})
|
||||
if reg ~= "" then
|
||||
return "@" .. reg
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
local extensions = {"man", "quickfix"}
|
||||
if pcall(require, "nvim-tree") then
|
||||
table.insert(extensions, "nvim-tree")
|
||||
end
|
||||
if pcall(require, "toggleterm") then
|
||||
table.insert(extensions, "toggleterm")
|
||||
end
|
||||
if pcall(require, "luapad.statusline") then
|
||||
table.insert(extensions, {
|
||||
sections = process_sections {
|
||||
lualine_a = {'mode'},
|
||||
lualine_b = {
|
||||
{
|
||||
'diagnostics',
|
||||
source = { 'nvim' },
|
||||
sections = { 'error' },
|
||||
diagnostics_color = { error = { bg = colors.red, fg = colors.white } },
|
||||
},
|
||||
{
|
||||
'diagnostics',
|
||||
source = { 'nvim' },
|
||||
sections = { 'warn' },
|
||||
diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } },
|
||||
},
|
||||
{ recording_macro, color = { bg = colors.orange } }
|
||||
},
|
||||
lualine_y = { search_result, 'filetype' },
|
||||
lualine_z = { '%l:%c', '%p%%/%L' },
|
||||
},
|
||||
filetypes = {'lua.luapad'}
|
||||
})
|
||||
end
|
||||
|
||||
require('lualine').setup {
|
||||
options = {
|
||||
theme = theme,
|
||||
component_separators = '',
|
||||
section_separators = { left = '', right = '' },
|
||||
-- ignore_focus = {"NvimTree"},
|
||||
globalstatus = true
|
||||
},
|
||||
sections = process_sections {
|
||||
lualine_a = { 'mode' },
|
||||
lualine_b = {
|
||||
'branch',
|
||||
'diff',
|
||||
{
|
||||
'diagnostics',
|
||||
source = { 'nvim' },
|
||||
sections = { 'error' },
|
||||
diagnostics_color = { error = { bg = colors.red, fg = colors.white } },
|
||||
},
|
||||
{
|
||||
'diagnostics',
|
||||
source = { 'nvim' },
|
||||
sections = { 'warn' },
|
||||
diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } },
|
||||
},
|
||||
{ 'filename', file_status = false, path = 1 },
|
||||
{ modified, color = { bg = colors.red } },
|
||||
{ '%w', cond = function() return vim.wo.previewwindow end },
|
||||
{ '%r', cond = function() return vim.bo.readonly end },
|
||||
{ '%q', cond = function() return vim.bo.buftype == 'quickfix' end },
|
||||
{ recording_macro, color = { bg = colors.orange } }
|
||||
},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
lualine_y = { search_result, 'filetype' },
|
||||
lualine_z = { '%l:%c', '%p%%/%L' },
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
extensions = extensions
|
||||
}
|
10
lua/config/luapad.lua
Normal file
10
lua/config/luapad.lua
Normal file
@ -0,0 +1,10 @@
|
||||
local pattern = "^/tmp/.*/%d+_Luapad%.lua$"
|
||||
local group = vim.api.nvim_create_augroup('LuaPadFiletype', {clear=true})
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = group,
|
||||
callback = function(data)
|
||||
if data.file:match(pattern) then
|
||||
vim.bo[data.buf].filetype = "lua.luapad"
|
||||
end
|
||||
end
|
||||
})
|
12
lua/config/move.lua
Normal file
12
lua/config/move.lua
Normal file
@ -0,0 +1,12 @@
|
||||
local opts = { noremap = true, silent = true }
|
||||
-- Normal-mode commands
|
||||
-- vim.keymap.set('n', '<A-j>', ':MoveLine(1)<CR>', opts)
|
||||
-- vim.keymap.set('n', '<A-k>', ':MoveLine(-1)<CR>', opts)
|
||||
-- vim.keymap.set('n', '<A-h>', ':MoveHChar(-1)<CR>', opts)
|
||||
-- vim.keymap.set('n', '<A-l>', ':MoveHChar(1)<CR>', opts)
|
||||
|
||||
-- Visual-mode commands
|
||||
vim.keymap.set('v', '<S-j>', ':MoveBlock(1)<CR>', opts)
|
||||
vim.keymap.set('v', '<S-k>', ':MoveBlock(-1)<CR>', opts)
|
||||
vim.keymap.set('v', '<S-h>', ':MoveHBlock(-1)<CR>', opts)
|
||||
vim.keymap.set('v', '<S-l>', ':MoveHBlock(1)<CR>', opts)
|
@ -1,2 +0,0 @@
|
||||
require("twilight").setup{
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
local map = require 'utils.map'
|
||||
|
||||
require("zen-mode").setup{
|
||||
window = {
|
||||
options = {
|
||||
number = false,
|
||||
relativenumber = false,
|
||||
cursorline = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
map('n', '<leader>z', ':ZenMode<cr>')
|
@ -4,13 +4,13 @@
|
||||
---@diagnostic disable-next-line: unused-local
|
||||
local function usePlugins(use, use_rocks)
|
||||
-- Toggle terminal
|
||||
use {'akinsho/toggleterm.nvim', tag = '*', config=[[require('config.toggleterm')]]}
|
||||
use { 'akinsho/toggleterm.nvim', tag = '*', load_config=true }
|
||||
|
||||
-- Colorize ANSI codes
|
||||
use { 'm00qek/baleia.nvim', tag = 'v1.2.0', config=[[require('config.baleia')]] }
|
||||
|
||||
-- Debugger
|
||||
use { 'mfussenegger/nvim-dap', config=[[require('config.dap')]]}
|
||||
use { 'mfussenegger/nvim-dap', config_name="dap" }
|
||||
use { "rcarriga/nvim-dap-ui", requires = "mfussenegger/nvim-dap", config=[[require('dapui').setup()]] }
|
||||
use 'simrat39/rust-tools.nvim'
|
||||
use {
|
||||
@ -20,7 +20,9 @@ local function usePlugins(use, use_rocks)
|
||||
}
|
||||
|
||||
-- Git blame
|
||||
use { 'f-person/git-blame.nvim', config=[[require("config.gitblame")]] }
|
||||
use { 'f-person/git-blame.nvim', config_name="gitblame" }
|
||||
|
||||
use { 'trmckay/based.nvim', load_config = true }
|
||||
|
||||
-- Seemless pane switching betwen tmux and vim
|
||||
use 'christoomey/vim-tmux-navigator'
|
||||
@ -28,30 +30,34 @@ local function usePlugins(use, use_rocks)
|
||||
-- UNIX commands
|
||||
use 'tpope/vim-eunuch'
|
||||
|
||||
use {'rafcamlet/nvim-luapad', config_name = "luapad"}
|
||||
|
||||
use { 'fedepujol/move.nvim', load_config=true }
|
||||
|
||||
-- fun
|
||||
use {'eandrju/cellular-automaton.nvim', load_config = true}
|
||||
|
||||
-- Movement utilities
|
||||
use 'tpope/vim-unimpaired'
|
||||
|
||||
-- LSP
|
||||
use {
|
||||
'neovim/nvim-lspconfig',
|
||||
config = [[require 'config.lspconfig']],
|
||||
}
|
||||
use { 'neovim/nvim-lspconfig', config_name = "lspconfig" }
|
||||
use {
|
||||
'williamboman/nvim-lsp-installer',
|
||||
requires = 'neovim/nvim-lspconfig',
|
||||
config = [[require 'config.lspinstaller']]
|
||||
config_name = "lspinstaller"
|
||||
}
|
||||
|
||||
-- LSP utils
|
||||
use {"ray-x/lsp_signature.nvim", config = [[require 'config.lspsignature']]}
|
||||
use {"ray-x/lsp_signature.nvim", config_name = "lspsignature"}
|
||||
use {
|
||||
'RishabhRD/nvim-lsputils',
|
||||
config = [[require 'config.lsputils']],
|
||||
config_name = "lsputils",
|
||||
requires = 'RishabhRD/popfix'
|
||||
}
|
||||
|
||||
-- Snippets
|
||||
use { 'L3MON4D3/LuaSnip', config = [[require 'config.luasnip']] }
|
||||
use { 'L3MON4D3/LuaSnip', config_name = "luasnip" }
|
||||
|
||||
-- Completion
|
||||
use { 'onsails/lspkind-nvim' }
|
||||
@ -60,9 +66,9 @@ local function usePlugins(use, use_rocks)
|
||||
-- requires = 'onsails/lspkind-nvim', -- For some reason breaks with this line
|
||||
requires = {'saadparwaiz1/cmp_luasnip'},
|
||||
after = 'lspkind-nvim',
|
||||
config = [[require 'config.cmp']]
|
||||
config_name = "cmp"
|
||||
}
|
||||
use {'tzachar/cmp-tabnine', after = 'nvim-cmp', run='./install.sh', requires = 'hrsh7th/nvim-cmp', config = [[require 'config.tabnine']]}
|
||||
use {'tzachar/cmp-tabnine', after = 'nvim-cmp', run='./install.sh', requires = 'hrsh7th/nvim-cmp', config_name = "tabnine"}
|
||||
use {'hrsh7th/cmp-nvim-lsp', requires = {'hrsh7th/nvim-cmp', 'nvim-lspconfig'}}
|
||||
use {'hrsh7th/cmp-nvim-lua', after = 'nvim-cmp', requires = 'hrsh7th/nvim-cmp'}
|
||||
use {'hrsh7th/cmp-buffer', after = 'nvim-cmp', requires = 'hrsh7th/nvim-cmp'}
|
||||
@ -74,7 +80,7 @@ local function usePlugins(use, use_rocks)
|
||||
use {
|
||||
'folke/trouble.nvim',
|
||||
requires = 'kyazdani42/nvim-web-devicons',
|
||||
config = [[require 'config.trouble']]
|
||||
load_config = true
|
||||
}
|
||||
|
||||
-- Color themes
|
||||
@ -93,11 +99,11 @@ local function usePlugins(use, use_rocks)
|
||||
use 'wellle/targets.vim'
|
||||
|
||||
-- Git integration
|
||||
use { 'tpope/vim-fugitive', config = [[require 'config.fugitive']] }
|
||||
use { 'tpope/vim-fugitive', config_name = "fugitive" }
|
||||
use {
|
||||
'lewis6991/gitsigns.nvim',
|
||||
requires = 'nvim-lua/plenary.nvim',
|
||||
config = [[require 'config.gitsigns']]
|
||||
load_config = true
|
||||
-- tag = 'release' -- To use the latest release
|
||||
}
|
||||
|
||||
@ -116,10 +122,15 @@ local function usePlugins(use, use_rocks)
|
||||
use 'tweekmonster/startuptime.vim'
|
||||
|
||||
-- Status line and tab line
|
||||
use { 'itchyny/lightline.vim', config = [[require 'config.lightline']]}
|
||||
-- use { 'itchyny/lightline.vim', config = [[require 'config.lightline']]}
|
||||
use {
|
||||
'nvim-lualine/lualine.nvim',
|
||||
requires = 'kyazdani42/nvim-web-devicons',
|
||||
load_config = true
|
||||
}
|
||||
|
||||
-- Load project specific settings from exrc
|
||||
use { 'jenterkin/vim-autosource', config = [[require 'config.autosource']] }
|
||||
use { 'jenterkin/vim-autosource', config_name = "autosource" }
|
||||
|
||||
-- Remove spaces at end of lines
|
||||
use{ "mcauley-penney/tidy.nvim", config = [[require("tidy").setup()]] }
|
||||
@ -130,9 +141,9 @@ local function usePlugins(use, use_rocks)
|
||||
|
||||
-- Quick movement
|
||||
-- use { 'justinmk/vim-sneak', config = [[require 'config.sneak']] }
|
||||
use { 'unblevable/quick-scope', config = [[require 'config.quickscope']] }
|
||||
use { 'unblevable/quick-scope', config_name = "quickscope" }
|
||||
use 'michaeljsmith/vim-indent-object'
|
||||
use { 'ggandor/leap.nvim', config=[[require 'config.leap']]}
|
||||
use { 'ggandor/leap.nvim', load_config = "leap"}
|
||||
|
||||
-- Smooth smooth scrolling
|
||||
-- use { 'karb94/neoscroll.nvim', config = [[require('neoscroll').setup()]] }
|
||||
@ -141,17 +152,17 @@ local function usePlugins(use, use_rocks)
|
||||
-- Commenting
|
||||
use {
|
||||
'terrortylor/nvim-comment',
|
||||
config = [[require 'config.comment']],
|
||||
config_name = "comment",
|
||||
requires = 'JoosepAlviste/nvim-ts-context-commentstring'
|
||||
}
|
||||
|
||||
-- Color code colorizer
|
||||
use { 'norcalli/nvim-colorizer.lua', config = [[require 'config.colorizer']] }
|
||||
use { 'norcalli/nvim-colorizer.lua', config_name = "colorizer" }
|
||||
|
||||
-- Fuzzy file finder
|
||||
use {
|
||||
'nvim-telescope/telescope.nvim',
|
||||
config = [[require 'config.telescope']],
|
||||
load_config = true,
|
||||
requires = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
@ -190,14 +201,6 @@ local function usePlugins(use, use_rocks)
|
||||
-- Dev icons
|
||||
use {'kyazdani42/nvim-web-devicons', config = [[require('nvim-web-devicons').setup()]]}
|
||||
|
||||
-- Zen mode
|
||||
use { 'folke/zen-mode.nvim', config = [[require 'config.zen-mode']] }
|
||||
use {
|
||||
'folke/twilight.nvim',
|
||||
requires = 'folke/zen-mode.nvim',
|
||||
config = [[require 'config.twilight']]
|
||||
}
|
||||
|
||||
-- File browser
|
||||
use {
|
||||
'kyazdani42/nvim-tree.lua',
|
||||
@ -237,6 +240,31 @@ local function bootstrap()
|
||||
end
|
||||
end
|
||||
|
||||
local function create_custom_use(use)
|
||||
return function (opts)
|
||||
if type(opts) == "string" then
|
||||
use(opts)
|
||||
return opts
|
||||
elseif type(opts) == "table" then
|
||||
if opts.load_config then
|
||||
local name = vim.split(opts[1], "/")[2]
|
||||
if name:match("%.nvim$") then
|
||||
name = name:sub(1, -6)
|
||||
end
|
||||
opts.config_name = name
|
||||
end
|
||||
if opts.config_name then
|
||||
opts.config = ("require('config.%s')"):format(opts.config_name)
|
||||
end
|
||||
use(opts)
|
||||
|
||||
return opts[1]
|
||||
else
|
||||
error("What are you doing???")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local packer = nil
|
||||
local function init()
|
||||
-- Perform bootstrap
|
||||
@ -259,7 +287,7 @@ local function init()
|
||||
packer.use 'wbthomason/packer.nvim'
|
||||
|
||||
-- Use plugins
|
||||
usePlugins(packer.use, packer.use_rocks)
|
||||
usePlugins(create_custom_use(packer.use), packer.use_rocks)
|
||||
|
||||
-- Automatically set up your configuration after cloning packer.nvim
|
||||
-- Put this at the end after all plugins
|
||||
|
Loading…
Reference in New Issue
Block a user