added neovim config
This commit is contained in:
commit
84afb34cee
21 changed files with 3105 additions and 0 deletions
74
dot_config/nvim/lua/config/cmp.lua
Normal file
74
dot_config/nvim/lua/config/cmp.lua
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
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,
|
||||
},
|
||||
window = {
|
||||
-- completion = cmp.config.window.bordered(),
|
||||
-- documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end)
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
-- { name = 'vsnip' }, -- For vsnip users.
|
||||
{ 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 = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
28
dot_config/nvim/lua/config/coq.lua
Normal file
28
dot_config/nvim/lua/config/coq.lua
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
local g = vim.g
|
||||
|
||||
g.coq_settings = {
|
||||
auto_start = "shut-up",
|
||||
keymap = { recommended = false }
|
||||
}
|
||||
|
||||
vim.api.nvim_set_keymap("i", "<Tab>", 'pumvisible() ? "\\<C-n>" : "\\<Tab>"', {
|
||||
expr = true
|
||||
})
|
||||
|
||||
vim.api.nvim_set_keymap("i", "<S-Tab>", 'pumvisible() ? "\\<C-p>" : "\\<S-Tab>"', {
|
||||
expr = true
|
||||
})
|
||||
|
||||
--Set completeopt to have a better completion experience
|
||||
vim.o.completeopt = "menuone,noinsert,noselect"
|
||||
|
||||
--Avoid showing message extra message when using completion
|
||||
vim.o.shortmess = vim.o.shortmess .. "c"
|
||||
|
||||
vim.g.completion_chain_complete_list = {
|
||||
default = {
|
||||
{ complete_items = { 'lsp', "buffer", "buffers" } },
|
||||
{ mode = { '<c-p>' } },
|
||||
{ mode = { '<c-n>' } }
|
||||
},
|
||||
}
|
||||
15
dot_config/nvim/lua/config/ctrlp.lua
Normal file
15
dot_config/nvim/lua/config/ctrlp.lua
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
local g = vim.g
|
||||
|
||||
g.ctrlp_map = "<leader>t"
|
||||
-- g.ctrlp_use_caching = 1
|
||||
-- g.ctrlp_clear_cache_on_exit = 0
|
||||
-- g.ctrlp_cache_dir = "./.vim/cache/ctrlp"
|
||||
g.ctrlp_user_command = {
|
||||
'.git', 'git --git-dir=%s/.git ls-files -oc --exclude-standard'
|
||||
}
|
||||
|
||||
--Limit max number of files
|
||||
--This prevents me from indexing my entire HOME by accident
|
||||
g.ctrlp_max_files = 1000
|
||||
--Also limit recursion depth
|
||||
g.ctrlp_max_depth = 10
|
||||
7
dot_config/nvim/lua/config/fugitive.lua
Normal file
7
dot_config/nvim/lua/config/fugitive.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- tpope/vim-fugitive
|
||||
nmap("<leader>gg", ":Git<CR>")
|
||||
nmap("<leader>gc", ":Git commit<CR>")
|
||||
nmap("<leader>gp", ":Git push<CR>")
|
||||
nmap("<leader>gd", ":Gdiffsplit!<CR>")
|
||||
nmap("<leader>gm", ":Git mergetool<CR>")
|
||||
nmap("<leader>gb", ":Git blame<CR>")
|
||||
3
dot_config/nvim/lua/config/gitgutter.lua
Normal file
3
dot_config/nvim/lua/config/gitgutter.lua
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
local g = vim.g
|
||||
|
||||
g.gitgutter_map_keys = 0
|
||||
75
dot_config/nvim/lua/config/lspconfig.lua
Normal file
75
dot_config/nvim/lua/config/lspconfig.lua
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
-- neovim/neovim-lspconfig
|
||||
local function on_attach(client, bufnr)
|
||||
local opts = {
|
||||
silent = true,
|
||||
noremap = true,
|
||||
}
|
||||
local function buf_nmap(mapping, cmd) vim.api.nvim_buf_set_keymap(bufnr, "n", mapping, cmd, opts) end
|
||||
|
||||
-- Jump to definition
|
||||
buf_nmap("gd", "<Cmd>lua vim.lsp.buf.definition()<CR>")
|
||||
-- Format current buffer on write
|
||||
vim.api.nvim_command([[autocmd BufWritePre <buffer> lua vim.lsp.buf.format()]])
|
||||
-- Show diagnostics for current line
|
||||
buf_nmap("<leader>dd", "<Cmd>lua vim.diagnostic.open_float()<CR>")
|
||||
-- Jump between diagnostic messages
|
||||
buf_nmap("<leader>dj", "<Cmd>lua vim.diagnostic.goto_next()<CR>")
|
||||
buf_nmap("<leader>dk", "<Cmd>lua vim.diagnostic.goto_prev()<CR>")
|
||||
-- Rename symbol under cursor
|
||||
buf_nmap("<leader>dr", "<Cmd>lua vim.lsp.buf.rename()<CR>")
|
||||
-- Show hover info
|
||||
buf_nmap("<leader>df", "<Cmd>lua vim.lsp.buf.hover()<CR>")
|
||||
buf_nmap("<leader>du", "<Cmd>lua vim.lsp.buf.references()<CR>")
|
||||
buf_nmap("<leader>da", "<Cmd>lua vim.lsp.buf.code_action()<CR>")
|
||||
end
|
||||
|
||||
-- For cmp autocomplete
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
|
||||
-- Comes with clang
|
||||
require'lspconfig'.clangd.setup{on_attach = on_attach, capabilities = capabilities}
|
||||
-- NPM: dockerfile-language-server-nodejs
|
||||
require'lspconfig'.dockerls.setup{capabilities = capabilities}
|
||||
-- Pacman: haskell-language-server
|
||||
-- AUR: haskell-language-server-bin
|
||||
-- GH: https://github.com/haskell/haskell-language-server
|
||||
require'lspconfig'.hls.setup{
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
haskell = {
|
||||
formattingProvider = "stylish-haskell"
|
||||
}
|
||||
},
|
||||
capabilities = capabilities
|
||||
}
|
||||
-- Pacman: vieter-vls (requires my Vieter repository)
|
||||
-- GH: https://github.com/vlang/vls
|
||||
-- require'lspconfig'.vls.setup{
|
||||
-- cmd = {'vls'},
|
||||
-- filetypes = {'v'},
|
||||
-- on_attach = on_attach
|
||||
-- }
|
||||
-- Pacman: rust-analyzer
|
||||
-- GH: https://github.com/rust-analyzer/rust-analyzer
|
||||
require'lspconfig'.rust_analyzer.setup{on_attach = on_attach, capabilities = capabilities}
|
||||
-- Installed using R shell:
|
||||
-- `install.packages('languageserver')`
|
||||
-- GH: https://github.com/REditorSupport/languageserver
|
||||
require'lspconfig'.r_language_server.setup{capabilities = capabilities}
|
||||
-- Installed using Go CLI:
|
||||
-- go install github.com/nametake/golangci-lint-langserver@latest
|
||||
-- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||
require'lspconfig'.gopls.setup{on_attach = on_attach, capabilities = capabilities}
|
||||
|
||||
require'lspconfig'.texlab.setup{on_attach = on_attach, capabilities = capabilities}
|
||||
|
||||
-- Fix that stops rust-analyzer interrupting typing when a request is cancelled
|
||||
for _, method in ipairs({ 'textDocument/diagnostic', 'workspace/diagnostic' }) do
|
||||
local default_diagnostic_handler = vim.lsp.handlers[method]
|
||||
vim.lsp.handlers[method] = function(err, result, context, config)
|
||||
if err ~= nil and err.code == -32802 then
|
||||
return
|
||||
end
|
||||
return default_diagnostic_handler(err, result, context, config)
|
||||
end
|
||||
end
|
||||
30
dot_config/nvim/lua/config/nerdtree.lua
Normal file
30
dot_config/nvim/lua/config/nerdtree.lua
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
local g = vim.g
|
||||
|
||||
g.NERDTreeIgnore = {
|
||||
'^\\.vim$[[dir]]',
|
||||
'^\\.vscode$[[dir]]', '.*\\.code-workspace$[[file]]', '^\\.idea$[[dir]]',
|
||||
'^__pycache__$[[dir]]', '^\\.pytest_cache$[[dir]]', '^venv$[[dir]]',
|
||||
'\\.egg-info$[[dir]]', '^dist$[[dir]]',
|
||||
'^\\.eggs$[[dir]]',
|
||||
'^out$[[dir]]',
|
||||
'^\\.git$[[dir]]',
|
||||
'^\\.stack-work$[[dir]]', '\\.lock$',
|
||||
'^CMakeFiles$[[dir]]', '^CMakeCache.txt$[[file]]',
|
||||
'.pdf$[[file]]',
|
||||
'^node_modules$[[dir]]',
|
||||
'\\.o$'
|
||||
}
|
||||
|
||||
g.NERDTreeShowHidden = 1
|
||||
g.NERDTreeMinimalUI = 1
|
||||
g.NERDTreeDirArrows = 1
|
||||
g.NERDTreeQuitOnOpen = 1
|
||||
g.NERDTreeChDirMode = 0
|
||||
g.NERDTreeNaturalSort = 1
|
||||
g.NERDTreeShowFiles = 1
|
||||
g.NERDTreeShowLineNumbers = 0
|
||||
g.NERDTreeWinPos = 'left'
|
||||
g.NERDTreeMinimalMenu = 1
|
||||
g.NERDTreeAutoDeleteBuffer = 1
|
||||
|
||||
nmap("tt", ":NERDTreeFind<CR>")
|
||||
12
dot_config/nvim/lua/config/tagbar.lua
Normal file
12
dot_config/nvim/lua/config/tagbar.lua
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
local g = vim.g
|
||||
|
||||
g.tagbar_map_nexttag = "J"
|
||||
g.tagbar_map_prevtag = "K"
|
||||
g.tagbar_map_showproto = "u"
|
||||
g.tagbar_sort = 0
|
||||
g.tagbar_compact = 1
|
||||
g.tagbar_autoshowtag = 1
|
||||
g.no_status_line = 1
|
||||
g.tagbar_autoclose = 1
|
||||
|
||||
nmap("tr", ":TagbarToggle<CR>")
|
||||
25
dot_config/nvim/lua/config/toggleterm.lua
Normal file
25
dot_config/nvim/lua/config/toggleterm.lua
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
vim.o.hidden = true
|
||||
|
||||
require("toggleterm").setup {
|
||||
-- open_mapping = "<leader>r",
|
||||
direction = "float",
|
||||
insert_mappings = false,
|
||||
start_in_insert = false
|
||||
}
|
||||
|
||||
local Terminal = require('toggleterm.terminal').Terminal
|
||||
local always_visible = Terminal:new{
|
||||
direction = "horizontal",
|
||||
count = 6
|
||||
}
|
||||
|
||||
function _always_visible_toggle()
|
||||
always_visible:toggle()
|
||||
end
|
||||
|
||||
nmap("<leader>rr", ":1ToggleTerm<CR>")
|
||||
nmap("<leader>ry", ":2ToggleTerm<CR>")
|
||||
nmap("<leader>ru", ":3ToggleTerm<CR>")
|
||||
nmap("<leader>ri", ":4ToggleTerm<CR>")
|
||||
nmap("<leader>ro", ":5ToggleTerm<CR>")
|
||||
nmap("<leader>rp", "<cmd>lua _always_visible_toggle()<CR>")
|
||||
5
dot_config/nvim/lua/config/treesitter.lua
Normal file
5
dot_config/nvim/lua/config/treesitter.lua
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
require"nvim-treesitter.configs".setup {
|
||||
highlight = { enable = true }
|
||||
}
|
||||
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
|
||||
parser_config.v = {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue