diff --git a/vim/.config/coc/extensions/db.json b/vim/.config/coc/extensions/db.json deleted file mode 100644 index 9e26dfe..0000000 --- a/vim/.config/coc/extensions/db.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/vim/.config/coc/extensions/package.json b/vim/.config/coc/extensions/package.json deleted file mode 100644 index d0ab58b..0000000 --- a/vim/.config/coc/extensions/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "dependencies": { - "coc-angular": ">=11.2.9", - "coc-css": ">=1.2.6", - "coc-emmet": ">=1.1.6", - "coc-esbonio": ">=0.4.0", - "coc-go": ">=0.13.3", - "coc-html": ">=1.4.1", - "coc-json": ">=1.3.4", - "coc-markdownlint": ">=1.11.1", - "coc-php-cs-fixer": ">=0.2.1", - "coc-phpactor": ">=1.0.3", - "coc-phpls": ">=2.2.0", - "coc-sh": ">=0.6.0", - "coc-svg": ">=0.0.13", - "coc-tailwindcss": ">=0.7.0", - "coc-tsserver": ">=1.7.0", - "coc-vetur": ">=1.2.4", - "coc-vimlsp": ">=0.12.2", - "coc-yaml": ">=1.3.1", - "coc-yank": ">=1.2.0" - } -} \ No newline at end of file diff --git a/vim/.config/coc/memos.json b/vim/.config/coc/memos.json deleted file mode 100644 index 9e26dfe..0000000 --- a/vim/.config/coc/memos.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/vim/.config/nvim/coc-settings.json b/vim/.config/nvim/coc-settings.json deleted file mode 100644 index 9dd169b..0000000 --- a/vim/.config/nvim/coc-settings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "diagnostic.messageTarget": "echo", - "diagnostic.virtualText": true, - - "intelephense.files.associations": [ - "*.inc", - "*.module", - "*.php", - "*.profile", - "*.test", - "*.theme" - ], - "intelephense.progress.enable": false, - "intelephense.telemetry.enabled": false -} diff --git a/vim/.config/nvim/init.vim b/vim/.config/nvim/init.vim index 50368f5..e2952b0 100644 --- a/vim/.config/nvim/init.vim +++ b/vim/.config/nvim/init.vim @@ -57,3 +57,5 @@ autocmd FileType gitcommit setlocal spell " Display extra whitespace set list listchars=tab:»·,trail:· + +lua require("opdavies") diff --git a/vim/.config/nvim/lua/opdavies/init.lua b/vim/.config/nvim/lua/opdavies/init.lua new file mode 100644 index 0000000..156ff58 --- /dev/null +++ b/vim/.config/nvim/lua/opdavies/init.lua @@ -0,0 +1,133 @@ +-- TreeSitter + +local configs = require'nvim-treesitter.configs' + +configs.setup { + ensure_installed = "maintained", + highlight = { + enable = true, + } +} + +-- LSP + +local lspconfig = require'lspconfig' +local completion = require'completion' + +local function custom_on_attach(client) + print('Attaching to ' .. client.name) + completion.on_attach(client) +end + +local default_config = { + on_attach = custom_on_attach, +} + +lspconfig.intelephense.setup{ + filetypes = { "install", "inc", "module", "php", "test", "theme" }, + on_attach = custom_on_attach, +} + +lspconfig.tsserver.setup(default_config) + +vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( + vim.lsp.diagnostic.on_publish_diagnostics, { + underline = true, + virtual_text = false, + signs = true, + update_in_insert = true, + } +) + +local key_mapper = function(mode, key, result) + vim.api.nvim_set_keymap( + mode, + key, + result, + {noremap = true, silent = true} + ) +end + +key_mapper('n', '', ':lua vim.lsp.buf.signature_help()') +key_mapper('n', 'af', ':lua vim.lsp.buf.code_action()') +key_mapper('n', 'rn', ':lua vim.lsp.buf.rename()') +key_mapper('n', 'K', ':lua vim.lsp.buf.hover()') +key_mapper('n', 'gD', ':lua vim.lsp.buf.declaration()') +key_mapper('n', 'gW', ':lua vim.lsp.buf.workspace_symbol()') +key_mapper('n', 'gd', ':lua vim.lsp.buf.definition()') +key_mapper('n', 'gi', ':lua vim.lsp.buf.implementation()') +key_mapper('n', 'gr', ':lua vim.lsp.buf.references()') +key_mapper('n', 'gt', ':lua vim.lsp.buf.type_definition()') +key_mapper('n', 'gw', ':lua vim.lsp.buf.document_symbol()') + +key_mapper('n', 'dn', ':lua vim.lsp.diagnostic.goto_next()') +key_mapper('n', 'dp', ':lua vim.lsp.diagnostic.goto_prev()') +key_mapper('n', 'ds', ':lua vim.lsp.diagnostic.show_line_diagnostics()') + +key_mapper('n', '', ':lua require"telescope.builtin".find_files()') +key_mapper('n', 'fb', ':lua require"telescope.builtin".buffers()') +key_mapper('n', 'fh', ':lua require"telescope.builtin".help_tags()') +key_mapper('n', 'fs', ':lua require"telescope.builtin".live_grep()') + +-- Compe +require'compe'.setup { + enabled = true; + autocomplete = true; + debug = false; + min_length = 1; + preselect = 'enable'; + throttle_time = 80; + source_timeout = 200; + incomplete_delay = 400; + max_abbr_width = 100; + max_kind_width = 100; + max_menu_width = 100; + documentation = true; + + source = { + path = true; + nvim_lsp = true; + }; +} + +local t = function(str) + return vim.api.nvim_replace_termcodes(str, true, true, true) +end + +local check_back_space = function() + local col = vim.fn.col('.') - 1 + if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then + return true + else + return false + end +end + +-- Use (s-)tab to: +--- move to prev/next item in completion menuone +--- jump to prev/next snippet's placeholder +_G.tab_complete = function() + if vim.fn.pumvisible() == 1 then + return t "" + elseif check_back_space() then + return t "" + else + return vim.fn['compe#complete']() + end +end +_G.s_tab_complete = function() + if vim.fn.pumvisible() == 1 then + return t "" + else + return t "" + end +end + +vim.api.nvim_set_keymap("i", "", "v:lua.tab_complete()", {expr = true}) +vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", {expr = true}) +vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", {expr = true}) +vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", {expr = true}) + +--This line is important for auto-import +vim.api.nvim_set_keymap('i', '', 'compe#confirm("")', { expr = true }) +vim.api.nvim_set_keymap('i', '', 'compe#complete()', { expr = true }) diff --git a/vim/.config/nvim/plugins.vim b/vim/.config/nvim/plugins.vim index d64e2ae..fd87768 100644 --- a/vim/.config/nvim/plugins.vim +++ b/vim/.config/nvim/plugins.vim @@ -5,14 +5,16 @@ Plug 'arcticicestudio/nord-vim' Plug 'christoomey/vim-sort-motion' Plug 'christoomey/vim-tmux-navigator' Plug 'editorconfig/editorconfig-vim' +Plug 'hrsh7th/nvim-compe' Plug 'jiangmiao/auto-pairs' -Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } -Plug 'junegunn/fzf.vim' Plug 'machakann/vim-highlightedyank' Plug 'mg979/vim-visual-multi', {'branch': 'master'} -Plug 'neoclide/coc.nvim', {'branch': 'release'} +Plug 'neovim/nvim-lspconfig' Plug 'nvim-lua/plenary.nvim' Plug 'nvim-lua/popup.nvim' +Plug 'nvim-telescope/telescope-fzy-native.nvim' +Plug 'nvim-telescope/telescope.nvim' +Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'preservim/nerdcommenter' Plug 'preservim/nerdtree' Plug 'sheerun/vim-polyglot' diff --git a/vim/.config/nvim/plugins/coc.vim b/vim/.config/nvim/plugins/coc.vim deleted file mode 100644 index e5b15d2..0000000 --- a/vim/.config/nvim/plugins/coc.vim +++ /dev/null @@ -1,8 +0,0 @@ -nmap a (coc-codeaction) -nmap gd (coc-definition) -nmap gr (coc-references) -nmap gi (coc-implementation) -nmap gt (coc-type-definition) -nmap sr (coc-rename) -nmap rf (coc-refactor) -nnoremap K :call show_documentation()