-- God forbid I ever have to use Windows, this should make it compatible local sep = vim.loop.os_uname().sysname == 'Windows_NT' and [[\]] or [[/]] local function join(...) return table.concat({ ... }, sep) end local home = os.getenv 'HOME' local len = #home local homepath = join(home, '.dotfiles', 'config-name') local cachepath = join(home, '.cache', 'config-name') -- Add path locations for configuration local rtp = { homepath, cachepath } -- Add paths that dont start with home. for _, p in ipairs(vim.opt.runtimepath:get()) do if p:sub(1, len) ~= home then rtp[#rtp + 1] = p end end vim.opt.runtimepath = rtp -- Packer paths and files local pack_path = join(homepath, 'site') local package_root = join(pack_path, 'pack') local compile_path = join(homepath, 'plugins', 'packer_compiled.lua') vim.g.loaded_remote_plugins = 1 vim.opt.packpath:prepend(pack_path) local packer_bootstrap = false local packer_install_path = join(package_root, 'packer', 'start', 'packer.nvim') if vim.fn.isdirectory(packer_install_path) == 0 then vim.fn.system { 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', packer_install_path } vim.cmd.packadd 'packer.nvim' packer_bootstrap = true end require('packer').startup { function(use) use 'wbthomason/packer.nvim' -- LSP - Language Server Protocol --use 'neovim/nvim-lspconfig' use 'hrsh7th/cmp-nvim-lsp' use 'hrsh7th/cmp-buffer' use 'hrsh7th/cmp-path' use 'hrsh7th/cmp-cmdline' use 'hrsh7th/nvim-cmp' -- TreeSitter - Syntax highlighting use 'nvim-treesitter/nvim-treesitter', {run = ':TSUpdate'} -- Fold-Cycle - Better management of foldable blocks use 'jghauser/fold-cycle.nvim' -- Git Gutter - Git diff markers use 'airblade/vim-gitgutter' -- Lightline - lightweight status/tabline beautification use 'itchyny/lightline.vim' -- Nerdtree - Tree explorer use 'preservim/nerdtree' -- Conqueror of Completion use 'neoclide/coc.nvim', {branch = 'release'} use 'bmeneg/coc-perl', {run = 'yarn install && yarn build'} -- use 'dart-lang/dart-vim-plugin' if packer_bootstrap then require('packer').sync() end end, config = { package_root = package_root, compile_path = compile_path, }, } 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 <lua vim.lsp.buf.declaration()', opts) buf_set_keymap('n', 'gd', 'tab split | lua vim.lsp.buf.definition()', opts) buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) buf_set_keymap('n', 't', 'lua vim.lsp.buf.signature_help()', opts) buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) buf_set_keymap('n', 'e', 'lua vim.diagnostic.open_float(0, {{opts2}, scope="line", border="rounded"})', opts) buf_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev({ float = { border = "rounded" }})', opts) buf_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next({ float = { border = "rounded" }})', opts) buf_set_keymap("n", "q", "lua vim.diagnostic.setloclist({open = true})", opts) -- Set some keybinds conditional on server capabilities if client.resolved_capabilities.document_formatting then buf_set_keymap("n", "lf", "lua vim.lsp.buf.formatting()", opts) end if client.resolved_capabilities.document_range_formatting then buf_set_keymap("n", "lf", "lua vim.lsp.buf.formatting()", 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', '', function() return require('fold-cycle').open() end, {silent = true, desc = 'Fold-cycle: open folds'}) vim.keymap.set('n', '', 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'}) vim.cmd([[ set foldmethod=expr set cursorline set foldexpr=nvim_treesitter#foldexpr() ]])