195 lines
6.8 KiB
VimL
195 lines
6.8 KiB
VimL
let plug_install = 0
|
|
let autoload_plug_path = stdpath('config') . '/autoload/plug.vim'
|
|
if !filereadable(autoload_plug_path)
|
|
silent exe '!curl -fL --create-dirs -o ' . autoload_plug_path .
|
|
\ ' https://raw.github.com/junegunn/vim-plug/master/plug.vim'
|
|
execute 'source ' . fnameescape(autoload_plug_path)
|
|
let plug_install = 1
|
|
endif
|
|
unlet autoload_plug_path
|
|
|
|
call plug#begin('~/.dotfiles/nvim/plugins')
|
|
" Plugins here
|
|
|
|
" LSP - Language Server Protocol
|
|
" Plug 'neovim/nvim-lspconfig'
|
|
Plug 'hrsh7th/cmp-nvim-lsp'
|
|
Plug 'hrsh7th/cmp-buffer'
|
|
Plug 'hrsh7th/cmp-path'
|
|
Plug 'hrsh7th/cmp-cmdline'
|
|
Plug 'hrsh7th/nvim-cmp'
|
|
" TreeSitter - Syntax highlighting
|
|
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
|
" Fold-Cycle - Better management of foldable blocks
|
|
Plug 'jghauser/fold-cycle.nvim'
|
|
" Git Gutter - Git diff markers
|
|
Plug 'airblade/vim-gitgutter'
|
|
" Lightline - lightweight status/tabline beautification
|
|
Plug 'itchyny/lightline.vim'
|
|
" Nerdtree - Tree explorer
|
|
Plug 'preservim/nerdtree'
|
|
" Conqueror of Completion
|
|
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
|
Plug 'bmeneg/coc-perl', {'do': 'yarn install && yarn build'}
|
|
" Dart lsp
|
|
Plug 'dart-lang/dart-vim-plugin'
|
|
|
|
call plug#end()
|
|
|
|
let g:coc_global_extensions = ['coc-json', 'coc-html', 'coc-python', 'coc-php', 'coc-perl', 'coc-flutter', 'coc-git']
|
|
if plug_install
|
|
PlugInstall --sync
|
|
endif
|
|
unlet plug_install
|
|
|
|
source $HOME/.dotfiles/vim/generic
|
|
|
|
lua <<EOF
|
|
require'nvim-treesitter.configs'.setup {
|
|
ensure_installed = {
|
|
"bash",
|
|
"c",
|
|
"cmake",
|
|
"cpp",
|
|
"css",
|
|
"dart",
|
|
"html",
|
|
"javascript",
|
|
"json",
|
|
"lua",
|
|
"make",
|
|
"markdown",
|
|
"perl",
|
|
"php",
|
|
"rasi",
|
|
"vim",
|
|
"yaml",
|
|
},
|
|
-- Install languages synchronously (only applied to `ensure_installed`)
|
|
sync_install = true,
|
|
-- List of parsers to ignore installing
|
|
ignore_install = { },
|
|
highlight = {
|
|
-- `false` will disable the whole extension
|
|
enable = true,
|
|
-- list of language that will be disabled
|
|
disable = { "" },
|
|
-- 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,
|
|
},
|
|
indent = {
|
|
-- dont enable this, messes up python indentation
|
|
enable = false,
|
|
disable = {},
|
|
},
|
|
}
|
|
|
|
-- local nvim_lsp = require('lspconfig')
|
|
local on_attach = function(client, bufnr)
|
|
local function buf_set_keymap(...)
|
|
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
|
end
|
|
local function buf_set_option(...)
|
|
vim.api.nvim_buf_set_option(bufnr, ...)
|
|
end
|
|
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
-- Mappings
|
|
local opts = { noremap=true, silent=false }
|
|
local opts2 = { focusable = false,
|
|
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
|
border = 'rounded',
|
|
source = 'always', -- show source in diagnostic popup window
|
|
prefix = ' '}
|
|
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
|
buf_set_keymap('n', 'gd', '<Cmd>tab split | lua vim.lsp.buf.definition()<CR>', opts)
|
|
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
|
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
|
buf_set_keymap('n', '<leader>t', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
|
buf_set_keymap('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
|
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
|
buf_set_keymap('n', '<leader>e', '<cmd>lua vim.diagnostic.open_float(0, {{opts2}, scope="line", border="rounded"})<CR>', opts)
|
|
buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev({ float = { border = "rounded" }})<CR>', opts)
|
|
buf_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next({ float = { border = "rounded" }})<CR>', opts)
|
|
buf_set_keymap("n", "<leader>q", "<cmd>lua vim.diagnostic.setloclist({open = true})<CR>", opts)
|
|
-- Set some keybinds conditional on server capabilities
|
|
if client.resolved_capabilities.document_formatting then
|
|
buf_set_keymap("n", "<leader>lf", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
|
end
|
|
if client.resolved_capabilities.document_range_formatting then
|
|
buf_set_keymap("n", "<leader>lf", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
|
end
|
|
end
|
|
-- NOTE: Don't use more than 1 servers otherwise nvim is unstable
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
-- Use pylsp
|
|
-- nvim_lsp.pylsp.setup({
|
|
-- on_attach = on_attach,
|
|
-- settings = {
|
|
-- pylsp = {
|
|
-- plugins = {
|
|
-- pylint = { enabled = true, executable = "pylint" },
|
|
-- pyflakes = { enabled = true },
|
|
-- pycodestyle = { enabled = false },
|
|
-- jedi_completion = { fuzzy = true },
|
|
-- pyls_isort = { enabled = true },
|
|
-- pylsp_mypy = { enabled = true },
|
|
-- },
|
|
-- }, },
|
|
-- flags = {
|
|
-- debounce_text_changes = 200,
|
|
-- },
|
|
-- capabilities = capabilities,
|
|
-- })
|
|
-- Use pyright or jedi_language_server
|
|
--local servers = {'jedi_language_server'}
|
|
--local servers = {'pyright'}
|
|
--for _, lsp in ipairs(servers) do
|
|
-- nvim_lsp[lsp].setup({
|
|
-- on_attach = on_attach,
|
|
-- capabilities = capabilities
|
|
--})
|
|
--end
|
|
-- Change diagnostic signs.
|
|
vim.fn.sign_define("DiagnosticSignError", { text = "✗", texthl = "DiagnosticSignError" })
|
|
vim.fn.sign_define("DiagnosticSignWarn", { text = "!", texthl = "DiagnosticSignWarn" })
|
|
vim.fn.sign_define("DiagnosticSignInformation", { text = "", texthl = "DiagnosticSignInfo" })
|
|
vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" })
|
|
-- global config for diagnostic
|
|
vim.diagnostic.config({
|
|
underline = false,
|
|
virtual_text = true,
|
|
signs = true,
|
|
severity_sort = true,
|
|
})
|
|
-- Change border of documentation hover window, See https://github.com/neovim/neovim/pull/13998.
|
|
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
|
|
border = "rounded",
|
|
})
|
|
|
|
-- require'lspconfig'.perlpls.setup()
|
|
|
|
require('fold-cycle').setup({
|
|
open_if_closed = true,
|
|
close_if_opened = true,
|
|
softwrap_movement_fix = true,
|
|
})
|
|
vim.keymap.set('n', '<tab>',
|
|
function() return require('fold-cycle').open() end,
|
|
{silent = true, desc = 'Fold-cycle: open folds'})
|
|
vim.keymap.set('n', '<s-tab>',
|
|
function() return require('fold-cycle').close() end,
|
|
{silent = true, desc = 'Fold-cycle: close folds'})
|
|
vim.keymap.set('n', 'zC',
|
|
function() return require('fold-cycle').close_all() end,
|
|
{remap = true, silent = true, desc = 'Fold-cycle: close all folds'})
|
|
EOF
|
|
|
|
set foldmethod=expr
|
|
set cursorline
|
|
set foldexpr=nvim_treesitter#foldexpr()
|