Browse Source

Init commit

pull/14/head
Ptrzl 3 years ago
commit
50e662a756
  1. 76
      .gitignore
  2. 1
      init.vim
  3. 79
      lua/configs/autocomplete.lua
  4. 95
      lua/configs/filetree.lua
  5. 30
      lua/configs/statusline.lua
  6. 32
      lua/core/init.lua
  7. 81
      lua/core/keymaps.lua
  8. 67
      lua/core/plugins.lua
  9. 17
      lua/core/theme.lua
  10. 205
      plugin/packer_compiled.lua

76
.gitignore

@ -0,0 +1,76 @@
# Created by https://www.toptal.com/developers/gitignore/api/linux,macos,windows
# Edit at https://www.toptal.com/developers/gitignore?templates=linux,macos,windows
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.toptal.com/developers/gitignore/api/linux,macos,windows

1
init.vim

@ -0,0 +1 @@
lua require('core.init')

79
lua/configs/autocomplete.lua

@ -0,0 +1,79 @@
-- Setup nvim-cmp.
local cmp = require'cmp'
cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
end,
},
mapping = {
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
-- { name = 'luasnip' }, -- For luasnip users.
-- { name = 'ultisnips' }, -- For ultisnips users.
-- { name = 'snippy' }, -- For snippy users.
}, {
{ name = 'buffer' },
})
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
-- nvim-lspconfig config
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { 'ccls' }
for _, lsp in pairs(servers) do
require('lspconfig')[lsp].setup {
on_attach = on_attach,
flags = {
-- This will be the default in neovim 0.7+
debounce_text_changes = 150,
}
}
end
-- C-CPP-Modern config
vim.g.cpp_function_highlight = 1
vim.g.cpp_attributes_highlight = 1
vim.g.cpp_member_highlight = 1
vim.g.cpp_simple_highlight = 1

95
lua/configs/filetree.lua

@ -0,0 +1,95 @@
-- nvim-tree config
require'nvim-tree'.setup {
disable_netrw = true,
hijack_netrw = true,
open_on_setup = true,
ignore_ft_on_setup = {},
auto_close = false,
auto_reload_on_write = true,
open_on_tab = false,
hijack_cursor = false,
update_cwd = false,
update_to_buf_dir = {
enable = true,
auto_open = true,
},
diagnostics = {
enable = false,
icons = {
hint = "",
info = "",
warning = "",
error = "",
}
},
update_focused_file = {
enable = false,
update_cwd = false,
ignore_list = {}
},
system_open = {
cmd = nil,
args = {}
},
filters = {
dotfiles = true,
custom = {}
},
git = {
enable = true,
ignore = true,
timeout = 500,
},
view = {
width = 30,
height = 30,
hide_root_folder = false,
side = 'left',
auto_resize = false,
mappings = {
custom_only = false,
list = {}
},
number = false,
relativenumber = false,
signcolumn = "yes"
},
trash = {
cmd = "trash",
require_confirm = true
},
actions = {
change_dir = {
global = false,
},
open_file = {
quit_on_open = false,
}
}
}
vim.cmd([[
let g:nvim_tree_icons = {
\ 'default': '',
\ 'symlink': '',
\ 'git': {
\ 'unstaged': "",
\ 'staged': "",
\ 'unmerged': "",
\ 'renamed': "",
\ 'untracked': "",
\ 'deleted': "",
\ 'ignored': ""
\ },
\ 'folder': {
\ 'arrow_open': "",
\ 'arrow_closed': "",
\ 'default': "",
\ 'open': "",
\ 'empty': "",
\ 'empty_open': "",
\ 'symlink': "",
\ 'symlink_open': "",
\ }
\ }
]])

30
lua/configs/statusline.lua

@ -0,0 +1,30 @@
-- lualine config
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = {},
always_divide_middle = true,
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {'filename'},
lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_y = {'progress'},
lualine_z = {'location'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = {},
lualine_z = {}
},
tabline = {},
extensions = {}
}

32
lua/core/init.lua

@ -0,0 +1,32 @@
require("core.keymaps")
require("core.plugins")
require("core.theme")
-- basics
--tabs
vim.cmd('syntax on')
vim.cmd('filetype plugin indent on')
vim.opt.autoindent = true
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.softtabstop = 4
vim.opt.expandtab = true
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.termguicolors = true
vim.opt.shiftround = true
vim.opt.updatetime=100
vim.opt.cursorline = true
vim.opt.autowrite = true
if vim.fn.has('termguicolors') then
vim.opt.termguicolors = true
end
require("configs.autocomplete")
require("configs.statusline")
-- bufferline config
require("bufferline").setup {}
require("configs.filetree")

81
lua/core/keymaps.lua

@ -0,0 +1,81 @@
vim.g.mapleader = ';'
local function map(mode, lhs, rhs)
vim.api.nvim_set_keymap(mode, lhs, rhs, {noremap=true})
end
local function mapcmd(key, cmd)
vim.api.nvim_set_keymap('n', key, ':'..cmd..'<cr>', {noremap=true})
end
-- keymaps
-- f: file tree
mapcmd('<leader>ft', 'NvimTreeToggle')
mapcmd('<leader>ff', 'NvimTreeFocus')
-- y: telescope
local telescope = require('telescope.builtin')
mapcmd('<leader>yo', "Telescope find_files")
mapcmd('<leader>yg', "Telescope live_grep")
mapcmd('<leader>yb', "Telescope buffers")
-- c: quick command
map('n', '<leader>ce', ':e<space>')
mapcmd('<leader>cw', 'w')
mapcmd('<leader>cW', 'wa')
mapcmd('<leader>cE', 'e!')
mapcmd('<leader>cq', 'q')
mapcmd('<leader>cQ', 'q!')
mapcmd('<leader>cx', 'x')
-- w: window
map('n', '<leader>wh', '<c-w>h')
map('n', '<leader>wj', '<c-w>j')
map('n', '<leader>wk', '<c-w>k')
map('n', '<leader>wl', '<c-w>l')
map('n', '<leader>w1', '<c-w>o')
mapcmd('<leader>wx', 'x')
mapcmd('<leader>w2', 'sp')
mapcmd('<leader>w3', 'vs')
-- window resize
map('n', '<m-9>', '<c-w><')
map('n', '<m-0>', '<c-w>>')
map('n', '<m-->', '<c-w>-')
map('n', '<m-=>', '<c-w>+')
map('n', '<m-r>', 'resize<space>')
map('n', '<m-t>', 'vertical resize<space>')
-- b: buffer
mapcmd('<leader>bn', 'bn')
mapcmd('<leader>bp', 'bp')
mapcmd('<leader>bd', 'Bdelete')
-- p: plugins
mapcmd('<leader>pi', 'PackerInstall')
mapcmd('<leader>pc', 'PackerClean')
-- s: search
map('n', '<leader>ss', '/')
map('n', '<leader>sw', '/\\<lt>\\><left><left>')
-- l/g/w: language
-- l: general
-- g: goto
-- w: workspace
mapcmd('<leader>le', 'lua vim.diagnostic.open_float()')
mapcmd('<leader>lq', 'lua vim.diagnostic.setloclist()')
mapcmd('<leader>lk', 'lua vim.lsp.buf.hover()')
mapcmd('<leader>lr', 'lua vim.lsp.buf.rename()')
mapcmd('<leader>lh', 'lua vim.lsp.buf.signature_help()')
mapcmd('<leader>la', 'lua vim.lsp.buf.code_action()')
mapcmd('<leader>lf', 'lua vim.lsp.buf.formatting()')
mapcmd('<leader>lb', 'TagbarToggle')
mapcmd('<leader>gD', 'lua vim.lsp.buf.declaration()')
mapcmd('<leader>gd', 'lua vim.lsp.buf.definition()')
mapcmd('<leader>gt', 'lua vim.lsp.buf.type_definition()')
mapcmd('<leader>gi', 'lua vim.lsp.buf.implementation()')
mapcmd('<leader>gp', 'lua vim.diagnostic.goto_prev()')
mapcmd('<leader>gn', 'lua vim.diagnostic.goto_next()')
mapcmd('<leader>gr', 'lua vim.lsp.buf.references()')
mapcmd('<leader>wa', 'lua vim.lsp.buf.add_workspace_folder()')
mapcmd('<leader>wr', 'lua vim.lsp.buf.remove_workspace_folder()')
mapcmd('<leader>wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))')
-- t: terminal
mapcmd('<leader>tn', 'FloatermNew')
mapcmd('<leader>tt', 'FloatermToggle')

67
lua/core/plugins.lua

@ -0,0 +1,67 @@
-- packer.nvim
vim.cmd [[packadd packer.nvim]]
return require('packer').startup(function()
use 'wbthomason/packer.nvim'
-- starup time optimise
use 'dstein64/vim-startuptime'
use 'lewis6991/impatient.nvim'
use 'nathom/filetype.nvim'
-- buffer
use {
'akinsho/bufferline.nvim',
requires = 'kyazdani42/nvim-web-devicons'
}
use 'moll/vim-bbye'
-- themes
use 'joshdick/onedark.vim'
use { 'catppuccin/nvim', as='catppuccin' }
use { 'sonph/onehalf', rtp='vim/' }
use 'sainnhe/sonokai'
use 'liuchengxu/space-vim-dark'
use 'ahmedabdulrahman/aylin.vim'
-- start screen
use 'matteogiorgi/vim-startscreen'
-- file tree
use {
'kyazdani42/nvim-tree.lua',
requires = 'kyazdani42/nvim-web-devicons'
}
-- language
use 'neovim/nvim-lspconfig'
use 'bfrg/vim-cpp-modern'
use 'hrsh7th/cmp-nvim-lsp'
use 'hrsh7th/cmp-buffer'
use 'hrsh7th/cmp-path'
use 'hrsh7th/cmp-cmdline'
use 'hrsh7th/nvim-cmp'
use 'L3MON4D3/LuaSnip'
-- git
use 'airblade/vim-gitgutter'
-- status line
use {
'nvim-lualine/lualine.nvim',
requires = 'kyazdani42/nvim-web-devicons'
}
-- tagbar
use 'preservim/tagbar'
-- floating terminal
use 'voldikss/vim-floaterm'
-- file telescope
use {
'nvim-telescope/telescope.nvim',
requires = 'nvim-lua/plenary.nvim'
}
end)

17
lua/core/theme.lua

@ -0,0 +1,17 @@
-- themes
-- sonokai
--sonokai styles: default, atlantis, andromeda, shusia, maia, espresso
vim.g.sonokai_style = 'andromeda'
vim.g.sonokai_enable_italic = 0
vim.g.sonokai_disable_italic_comment = 0
vim.cmd('colorscheme sonokai')
-- onedark
--vim.cmd('colorscheme onedark')
-- onehalfdark
--vim.cmd('colorscheme onehalfdark')
--vim.cmd('colorscheme onehalflight')
-- space-vim-dark
--vim.cmd('colorscheme space-vim-dark')
-- aylin
--vim.cmd('colorscheme aylin')

205
plugin/packer_compiled.lua

@ -0,0 +1,205 @@
-- 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 = "/Users/peterluo/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/Users/peterluo/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/Users/peterluo/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/Users/peterluo/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/Users/peterluo/.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), name, _G.packer_plugins[name])
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 = {
YouCompleteMe = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/YouCompleteMe",
url = "https://github.com/ycm-core/YouCompleteMe"
},
["aylin.vim"] = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/aylin.vim",
url = "https://github.com/ahmedabdulrahman/aylin.vim"
},
["bufferline.nvim"] = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/bufferline.nvim",
url = "https://github.com/akinsho/bufferline.nvim"
},
catppuccin = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/catppuccin",
url = "https://github.com/catppuccin/nvim"
},
["filetype.nvim"] = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/filetype.nvim",
url = "https://github.com/nathom/filetype.nvim"
},
["impatient.nvim"] = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/impatient.nvim",
url = "https://github.com/lewis6991/impatient.nvim"
},
["lualine.nvim"] = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/lualine.nvim",
url = "https://github.com/nvim-lualine/lualine.nvim"
},
nerdtree = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/nerdtree",
url = "https://github.com/preservim/nerdtree"
},
["nerdtree-git-plugin"] = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/nerdtree-git-plugin",
url = "https://github.com/Xuyuanp/nerdtree-git-plugin"
},
["nvim-web-devicons"] = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/nvim-web-devicons",
url = "https://github.com/kyazdani42/nvim-web-devicons"
},
["onedark.vim"] = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/onedark.vim",
url = "https://github.com/joshdick/onedark.vim"
},
onehalf = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/onehalf/vim/",
url = "https://github.com/sonph/onehalf"
},
["packer.nvim"] = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/packer.nvim",
url = "https://github.com/wbthomason/packer.nvim"
},
sonokai = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/sonokai",
url = "https://github.com/sainnhe/sonokai"
},
["space-vim-dark"] = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/space-vim-dark",
url = "https://github.com/liuchengxu/space-vim-dark"
},
tagbar = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/tagbar",
url = "https://github.com/preservim/tagbar"
},
ultisnips = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/ultisnips",
url = "https://github.com/SirVer/ultisnips"
},
["vim-bbye"] = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/vim-bbye",
url = "https://github.com/moll/vim-bbye"
},
["vim-cpp-modern"] = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/vim-cpp-modern",
url = "https://github.com/bfrg/vim-cpp-modern"
},
["vim-devicons"] = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/vim-devicons",
url = "https://github.com/ryanoasis/vim-devicons"
},
["vim-gitgutter"] = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/vim-gitgutter",
url = "https://github.com/airblade/vim-gitgutter"
},
["vim-snippets"] = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/vim-snippets",
url = "https://github.com/honza/vim-snippets"
},
["vim-startscreen"] = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/vim-startscreen",
url = "https://github.com/matteogiorgi/vim-startscreen"
},
["vim-startuptime"] = {
loaded = true,
path = "/Users/peterluo/.local/share/nvim/site/pack/packer/start/vim-startuptime",
url = "https://github.com/dstein64/vim-startuptime"
}
}
time([[Defining packer_plugins]], false)
-- Runtimepath customization
time([[Runtimepath customization]], true)
vim.o.runtimepath = vim.o.runtimepath .. ",/Users/peterluo/.local/share/nvim/site/pack/packer/start/onehalf/vim/"
time([[Runtimepath customization]], 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
Loading…
Cancel
Save