lspconfig - add snippet support, fix css

This commit is contained in:
Ray Elliott 2021-09-19 13:01:52 +01:00
parent aaf41ab39e
commit b3e1ce732b
5 changed files with 57 additions and 52 deletions

View File

@ -1,3 +1,15 @@
snippet pp "<?php ... ?>"
<?php $0; ?>
endsnippet
snippet pe "<?php ... ?>"
<?php echo "$0"; ?>
endsnippet
snippet ph "<?php ... ?>"
<?php esc_html( $0 ); ?>
endsnippet
snippet pf "public function ..."
public function $1($2) {
$0

View File

@ -58,7 +58,7 @@ Plug '~/nvim-paper-tonic'
Plug 'hrsh7th/cmp-nvim-lsp', { 'branch': 'main' }
Plug 'hrsh7th/cmp-buffer', { 'branch': 'main' }
Plug 'hrsh7th/cmp-path', { 'branch': 'main' }
" Plug 'hrsh7th/cmp-nvim-ultisnips'
Plug 'quangnguyen30192/cmp-nvim-ultisnips', { 'branch': 'main' }
"}}}

View File

@ -11,32 +11,6 @@ require'nvim-treesitter.configs'.setup {
additional_vim_regex_highlighting = false,
},
}
-- https://github.com/neovim/nvim-lspconfig
-- https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md
-- npm install -g typescript typescript-language-server
require'lspconfig'.tsserver.setup{}
-- npm install -g vim-language-server
require'lspconfig'.vimls.setup{}
-- npm install -g pyright
require'lspconfig'.pyright.setup{}
-- phpactor installation -
-- https://phpactor.readthedocs.io/en/master/usage/standalone.html
require'lspconfig'.phpactor.setup{}
-- npm i -g vscode-langservers-extracted
require'lspconfig'.intelephense.setup{}
-- npm install -g intelephense
require'lspconfig'.cssls.setup{}
-- npm install -g vls
require'lspconfig'.vuels.setup{}
-- npm i -g bash-language-server
-- TODO - don't run for sh files but have something else instead - shellcheck?
require'lspconfig'.bashls.setup{}
-- npm install -g yaml-language-server
require'lspconfig'.yamlls.setup{}
-- npm i -g stylelint-lsp
require'lspconfig'.stylelint_lsp.setup{}
-- https://github.com/neovim/nvim-lspconfig/wiki
require'lspconfig'.tailwindcss.setup{}
--[efm-langserver]
@ -110,20 +84,48 @@ require "lspconfig".efm.setup {
}
}
-- [lspconfig]
local nvim_lsp = require('lspconfig')
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = {
-- npm i -g bash-language-server
-- TODO - don't run for sh files but have something else instead - shellcheck?
'bashls',
-- npm i -g vscode-langservers-extracted
'cssls',
-- npm install -g intelephense
'intelephense',
-- https://phpactor.readthedocs.io/en/master/usage/standalone.html
'phpactor',
-- npm install -g pyright
'pyright',
-- npm i -g stylelint-lsp
'stylelint_lsp',
-- https://github.com/neovim/nvim-lspconfig/wiki
'tailwindcss',
-- npm install -g typescript typescript-language-server
'tsserver',
-- npm install -g vim-language-server
'vimls',
-- npm install -g vls
'vuels',
-- npm i -g stylelint-lsp
'yamlls',
}
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
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
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
-- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
local opts = { noremap=true, silent=true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
@ -142,26 +144,15 @@ local on_attach = function(client, bufnr)
-- buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
-- buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
-- buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
end
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = {
'bashls',
'cssls',
'intelephense',
'phpactor',
'pyright',
'stylelint_lsp',
'tailwindcss',
'tsserver',
'vimls',
'vuels'
}
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach = on_attach,
capabilities = capabilities,
flags = {
debounce_text_changes = 150,
}
@ -174,11 +165,11 @@ cmp.setup({
keyword_length = 4
-- autocomplete = false
},
-- snippet = {
-- expand = function(args)
-- vim.fn["vsnip#anonymous"](args.body)
-- end,
-- },
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
['<C-n>'] = cmp.mapping.complete(),
['<C-y>'] = cmp.mapping.confirm({ select = true }),
@ -188,7 +179,7 @@ cmp.setup({
{ name = 'buffer' },
{ name = 'nvim_lsp' },
{ name = 'path' },
--{ name = 'ultisnips' },
{ name = 'ultisnips' },
...
}
})

View File

@ -174,3 +174,5 @@ erimplement
particularly
movie
multivariable
Unsetting
ajax

Binary file not shown.