Add everything and LSP doesn work.

This commit is contained in:
juan 2021-09-07 23:26:21 +08:00
commit ea148c695e
16 changed files with 514 additions and 0 deletions

3
init.lua Normal file
View File

@ -0,0 +1,3 @@
require('core')
require('pluginList')
require('mappings')

18
lua/core.lua Normal file
View File

@ -0,0 +1,18 @@
-- Core Settings
local opt = vim.o
-- look and feel
opt.relativenumber = true
opt.number = true
opt.showmode = false
opt.scrolloff = 10
opt.ruler = true
opt.termguicolors = true
opt.shiftwidth = 2
-- controlling
opt.ignorecase = true
opt.smartcase = true
opt.smartindent = true
opt.mouse = "i"

23
lua/mappings.lua Normal file
View File

@ -0,0 +1,23 @@
-- generic mappings
vim.api.nvim_set_keymap('v', '<', '<gv', {noremap = true})
vim.api.nvim_set_keymap('v', '>', '>gv', {noremap = true})
vim.api.nvim_set_keymap('n', 'Y', 'y$', {noremap = true})
vim.api.nvim_set_keymap('n', 'n', 'nzzzv', {noremap = true})
vim.api.nvim_set_keymap('n', 'N', 'Nzzzv', {noremap = true})
-- Shortcutting split navigation
vim.api.nvim_set_keymap('', '<A-h>', '<C-w>h', {})
vim.api.nvim_set_keymap('', '<A-j>', '<C-w>j', {})
vim.api.nvim_set_keymap('', '<A-k>', '<C-w>k', {})
vim.api.nvim_set_keymap('', '<A-l>', '<C-w>l', {})
vim.api.nvim_set_keymap('', '<A-H>', '<C-w>H', {})
vim.api.nvim_set_keymap('', '<A-J>', '<C-w>J', {})
vim.api.nvim_set_keymap('', '<A-K>', '<C-w>K', {})
vim.api.nvim_set_keymap('', '<A-L>', '<C-w>L', {})
vim.api.nvim_set_keymap('', '<A->>', '<C-w>>', {})
vim.api.nvim_set_keymap('', '<A-<>', '<C-w><', {})
-- undo to the last , . or !
vim.api.nvim_set_keymap('i', ',', ',<c-g>u', {noremap = true})
vim.api.nvim_set_keymap('i', '.', '.<c-g>u', {noremap = true})
vim.api.nvim_set_keymap('i', '!', '!<c-g>u', {noremap = true})
vim.api.nvim_set_keymap('i', '?', '?<c-g>u', {noremap = true})

96
lua/pluginList.lua Normal file
View File

@ -0,0 +1,96 @@
-- Only required if you have packer configured as `opt`
vim.cmd [[packadd packer.nvim]]
require('packer').init {
opt_default = true,
display = {
open_fn = function()
return require("packer.util").float {border = "single"}
end,
prompt_border = "single"
},
git = {
clone_timeout = 600 -- Timeout, in seconds, for git clones
},
auto_clean = true,
compile_on_sync = true
-- auto_reload_compiled = true
}
return require('packer').startup(function(use)
use {'wbthomason/packer.nvim', event = 'VimEnter'}
-- core UI
use {'kyazdani42/nvim-web-devicons', after = 'packer.nvim'}
use {
'hoob3rt/lualine.nvim',
after = 'nvim-web-devicons',
config = function() require "plugins.statusline" end
}
use {
'RRethy/nvim-base16',
event = 'VimEnter',
config = function() require "plugins.base16" end
}
-- lsp stuff
use {
'nvim-treesitter/nvim-treesitter',
event = 'BufRead',
config = function() require "plugins.treesitter" end,
run = ':TSUpdate'
}
use {'neovim/nvim-lspconfig', event = 'BufRead'}
use {
'kabouzeid/nvim-lspinstall',
after = 'nvim-lspconfig',
config = function() require "plugins.lspinstall" end
}
use {'onsails/lspkind-nvim', after = 'nvim-lspconfig'}
use {"ray-x/lsp_signature.nvim", after = 'nvim-lspconfig'}
-- packer
use {
'ms-jpq/coq_nvim',
branch = 'coq',
requires = {'ms-jpq/coq.artifacts', branch = 'artifacts'}
}
-- formating and editing
use {"sbdchd/neoformat", cmd = "Neoformat"}
use {
"mattn/emmet-vim",
event = "FileType html,css",
setup = function() require "plugins.emmet" end
}
use {"machakann/vim-sandwich", event = "BufRead"}
-- navigation
use {
'kyazdani42/nvim-tree.lua',
cmd = 'NvimTreeToggle',
requires = 'kyazdani42/nvim-web-devicons'
}
use {
"vimwiki/vimwiki",
cmd = "VimwikiIndex",
setup = function() require "plugins.vimwiki" end
}
use {
'andymass/vim-matchup',
after = 'nvim-treesitter',
config = function() require "plugins.matchup" end
}
-- eye-candy
use {
'sunjon/shade.nvim',
event = "BufAdd",
config = function() require "plugins.shade" end
}
use {
"lukas-reineke/indent-blankline.nvim",
after = {"nvim-treesitter","nvim-base16"},
config = function() require "plugins.indent-blankline" end
}
end)

19
lua/plugins/base16.lua Normal file
View File

@ -0,0 +1,19 @@
require('base16-colorscheme').setup({
base00 = "#161821",
base01 = "#1e2132",
base02 = "#818596",
base03 = "#6b7089",
base04 = "#161821",
base05 = "#c6c8d1",
base06 = "#e2a478",
base07 = "#e9b189",
base08 = "#89b8c2",
base09 = "#e98989",
base0A = "#e2a478",
base0B = "#b4be82",
base0C = "#91acd1",
base0D = "#84a0c6",
base0E = "#a093c7",
base0F = "#e27878"
})

1
lua/plugins/emmet.lua Normal file
View File

@ -0,0 +1 @@
vim.g.emmet_html5 = 1

View File

@ -0,0 +1,9 @@
require("indent_blankline").setup {
buftype_exclude = {"terminal", "help","packer"},
indent_blankline_buftype_exclude = {"terminal"},
indentLine_enabled = 1,
indent_blankline_char = "",
show_current_context = true,
indent_blankline_show_trailing_blankline_indent = false,
indent_blankline_show_first_indent_level = false
}

View File

@ -0,0 +1,26 @@
local function setup_servers()
require'lspinstall'.setup(coq.lsp_ensure_capabilities())
local servers = require'lspinstall'.installed_servers()
for _, server in pairs(servers) do require'lspconfig'[server].setup {} end
end
-- Automatically reload after `:LspInstall <server>` so we don't have to restart neovim
require'lspinstall'.post_install_hook = function()
setup_servers() -- reload installed servers
vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server
end
-- setup coq.lua
local lsp = require 'lspconfig'
require("packer").loader("coq_nvim coq.artifacts")
vim.g.coq_settings = {auto_start = true, clients = {tabnine = {enabled = true}}}
local coq = require 'coq'
setup_servers()
lsp.gopls.setup(coq.lsp_ensure_capabilities({
cmd = {"gopls", "serve"},
settings = {gopls = {analyses = {unusedparams = true}, staticcheck = true}}
}))
-- load coq.lua
vim.cmd("COQnow -s")

5
lua/plugins/matchup.lua Normal file
View File

@ -0,0 +1,5 @@
require'nvim-treesitter.configs'.setup {
matchup = {
enable = true -- mandatory, false will disable the whole extension
}
}

7
lua/plugins/shade.lua Normal file
View File

@ -0,0 +1,7 @@
require'shade'.setup({
overlay_opacity = 50,
opacity_step = 1,
keys = {
toggle = '<Leader>s',
}
})

View File

@ -0,0 +1,27 @@
require'lualine'.setup {
options = {
icons_enabled = true,
theme = 'iceberg_dark',
component_separators = {'|', '|'},
section_separators = {'', ''},
disabled_filetypes = {}
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch'},
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 = {}
}

View File

@ -0,0 +1,15 @@
require'nvim-treesitter.configs'.setup {
ensure_installed = {"lua"}, -- one of "all", "maintained" (parsers with maintainers), or a list of languages
highlight = {
enable = true, -- false will disable the whole extension
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
use_languagetree = true
},
indent = {
enable = true
}
}

4
lua/plugins/vimwiki.lua Normal file
View File

@ -0,0 +1,4 @@
vim.api.nvim_set_var('vimwiki_global_ext', 0)
vim.cmd([[
let g:vimwiki_list = [{'path': '~/Documents/Personal/Wiki/', 'syntax': 'markdown', 'ext': '.md'}]
]])

244
plugin/packer_compiled.lua Normal file
View File

@ -0,0 +1,244 @@
-- 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/juan/.cache/nvim/packer_hererocks/2.0.5/share/lua/5.1/?.lua;/home/juan/.cache/nvim/packer_hererocks/2.0.5/share/lua/5.1/?/init.lua;/home/juan/.cache/nvim/packer_hererocks/2.0.5/lib/luarocks/rocks-5.1/?.lua;/home/juan/.cache/nvim/packer_hererocks/2.0.5/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/home/juan/.cache/nvim/packer_hererocks/2.0.5/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 = {
["coq.artifacts"] = {
load_after = {
coq_nvim = true
},
loaded = false,
needs_bufread = false,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/coq.artifacts"
},
coq_nvim = {
after = { "coq.artifacts" },
loaded = false,
needs_bufread = true,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/coq_nvim"
},
["emmet-vim"] = {
loaded = false,
needs_bufread = false,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/emmet-vim"
},
["indent-blankline.nvim"] = {
config = { "\27LJ\1\0028\0\0\2\0\2\0\0044\0\0\0%\1\1\0>\0\2\1G\0\1\0\29plugins.indent-blankline\frequire\0" },
load_after = {
["nvim-base16"] = true,
["nvim-treesitter"] = true
},
loaded = false,
needs_bufread = false,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/indent-blankline.nvim"
},
["lsp_signature.nvim"] = {
load_after = {
["nvim-lspconfig"] = true
},
loaded = false,
needs_bufread = false,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/lsp_signature.nvim"
},
["lspkind-nvim"] = {
load_after = {
["nvim-lspconfig"] = true
},
loaded = false,
needs_bufread = false,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/lspkind-nvim"
},
["lualine.nvim"] = {
config = { "\27LJ\1\0022\0\0\2\0\2\0\0044\0\0\0%\1\1\0>\0\2\1G\0\1\0\23plugins.statusline\frequire\0" },
load_after = {
["nvim-web-devicons"] = true
},
loaded = false,
needs_bufread = false,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/lualine.nvim"
},
neoformat = {
commands = { "Neoformat" },
loaded = false,
needs_bufread = false,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/neoformat"
},
["nvim-base16"] = {
after = { "indent-blankline.nvim" },
config = { "\27LJ\1\2.\0\0\2\0\2\0\0044\0\0\0%\1\1\0>\0\2\1G\0\1\0\19plugins.base16\frequire\0" },
loaded = false,
needs_bufread = false,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/nvim-base16"
},
["nvim-lspconfig"] = {
after = { "lsp_signature.nvim", "lspkind-nvim", "nvim-lspinstall" },
loaded = false,
needs_bufread = false,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/nvim-lspconfig"
},
["nvim-lspinstall"] = {
config = { "\27LJ\1\0022\0\0\2\0\2\0\0044\0\0\0%\1\1\0>\0\2\1G\0\1\0\23plugins.lspinstall\frequire\0" },
load_after = {
["nvim-lspconfig"] = true
},
loaded = false,
needs_bufread = false,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/nvim-lspinstall"
},
["nvim-tree.lua"] = {
commands = { "NvimTreeToggle" },
loaded = false,
needs_bufread = false,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/nvim-tree.lua"
},
["nvim-treesitter"] = {
after = { "indent-blankline.nvim", "vim-matchup" },
config = { "\27LJ\1\0022\0\0\2\0\2\0\0044\0\0\0%\1\1\0>\0\2\1G\0\1\0\23plugins.treesitter\frequire\0" },
loaded = false,
needs_bufread = true,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/nvim-treesitter"
},
["nvim-web-devicons"] = {
after = { "lualine.nvim" },
load_after = {
["packer.nvim"] = true
},
loaded = false,
needs_bufread = false,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/nvim-web-devicons"
},
["packer.nvim"] = {
after = { "nvim-web-devicons" },
loaded = false,
needs_bufread = false,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/packer.nvim"
},
["shade.nvim"] = {
config = { "\27LJ\1\2-\0\0\2\0\2\0\0044\0\0\0%\1\1\0>\0\2\1G\0\1\0\18plugins.shade\frequire\0" },
loaded = false,
needs_bufread = false,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/shade.nvim"
},
["vim-matchup"] = {
after_files = { "/home/juan/.local/share/nvim/site/pack/packer/opt/vim-matchup/after/plugin/matchit.vim" },
config = { "\27LJ\1\2/\0\0\2\0\2\0\0044\0\0\0%\1\1\0>\0\2\1G\0\1\0\20plugins.matchup\frequire\0" },
load_after = {
["nvim-treesitter"] = true
},
loaded = false,
needs_bufread = true,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/vim-matchup"
},
["vim-sandwich"] = {
loaded = false,
needs_bufread = true,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/vim-sandwich"
},
vimwiki = {
commands = { "VimwikiIndex" },
loaded = false,
needs_bufread = true,
path = "/home/juan/.local/share/nvim/site/pack/packer/opt/vimwiki"
}
}
time([[Defining packer_plugins]], false)
-- Setup for: emmet-vim
time([[Setup for emmet-vim]], true)
try_loadstring("\27LJ\1\2-\0\0\2\0\2\0\0044\0\0\0%\1\1\0>\0\2\1G\0\1\0\18plugins.emmet\frequire\0", "setup", "emmet-vim")
time([[Setup for emmet-vim]], false)
-- Setup for: vimwiki
time([[Setup for vimwiki]], true)
try_loadstring("\27LJ\1\2/\0\0\2\0\2\0\0044\0\0\0%\1\1\0>\0\2\1G\0\1\0\20plugins.vimwiki\frequire\0", "setup", "vimwiki")
time([[Setup for vimwiki]], false)
-- Command lazy-loads
time([[Defining lazy-load commands]], true)
pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Neoformat lua require("packer.load")({'neoformat'}, { cmd = "Neoformat", l1 = <line1>, l2 = <line2>, bang = <q-bang>, args = <q-args> }, _G.packer_plugins)]])
pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file VimwikiIndex lua require("packer.load")({'vimwiki'}, { cmd = "VimwikiIndex", l1 = <line1>, l2 = <line2>, bang = <q-bang>, args = <q-args> }, _G.packer_plugins)]])
pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file NvimTreeToggle lua require("packer.load")({'nvim-tree.lua'}, { cmd = "NvimTreeToggle", l1 = <line1>, l2 = <line2>, bang = <q-bang>, args = <q-args> }, _G.packer_plugins)]])
time([[Defining lazy-load commands]], false)
vim.cmd [[augroup packer_load_aucmds]]
vim.cmd [[au!]]
-- Event lazy-loads
time([[Defining lazy-load event autocommands]], true)
vim.cmd [[au BufAdd * ++once lua require("packer.load")({'shade.nvim'}, { event = "BufAdd *" }, _G.packer_plugins)]]
vim.cmd [[au FileType html,css ++once lua require("packer.load")({'emmet-vim'}, { event = "FileType html,css" }, _G.packer_plugins)]]
vim.cmd [[au VimEnter * ++once lua require("packer.load")({'packer.nvim', 'nvim-base16'}, { event = "VimEnter *" }, _G.packer_plugins)]]
vim.cmd [[au BufRead * ++once lua require("packer.load")({'nvim-treesitter', 'nvim-lspconfig', 'vim-sandwich'}, { event = "BufRead *" }, _G.packer_plugins)]]
time([[Defining lazy-load event autocommands]], false)
vim.cmd("augroup END")
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

12
test.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
cd ~/.config/
mv nvim nvim.bak
mv nvim.new nvim
mv /home/juan/.local/share/nvim/site/pack /home/juan/.local/share/nvim/site/pack.bak
mv /home/juan/.local/share/nvim/site/pack.new /home/juan/.local/share/nvim/site/pack
# nvim
# mv nvim nvim.new
# mv nvim.bak nvim
# mv /home/juan/.local/share/nvim/site/pack /home/juan/.local/share/nvim/site/pack.new
# mv /home/juan/.local/share/nvim/site/pack.bak /home/juan/.local/share/nvim/site/pack

5
untest.sh Executable file
View File

@ -0,0 +1,5 @@
mv nvim nvim.new
mv nvim.bak nvim
mv /home/juan/.local/share/nvim/site/pack /home/juan/.local/share/nvim/site/pack.new
mv /home/juan/.local/share/nvim/site/pack.bak /home/juan/.local/share/nvim/site/pack