Changed some nvim config stuff

This commit is contained in:
Dreaded_X 2022-01-28 21:57:04 +01:00
parent c0b519ed25
commit 795552cf2e
4 changed files with 200 additions and 96 deletions

View File

@ -10,18 +10,21 @@ let delimitMate_balance_matchpairs = 1
" Theme
colorscheme gruvbox
" colorscheme codedark
set t_Co=256
set t_ZH=
set t_ZR=
set background=dark
" Ident
set list lcs=tab:┃\ ,trail
" set list lcs=tab:┃\ ,trail:·
set list lcs=tab:¦\ ,trail
" Airline
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline_theme='gruvbox'
" let g:airline_theme='codedark'
let g:airline_section_z = '%3p%% %#__accent_bold#%4l%#__restore__#%#__accent_bold#/%L%#__restore__# :%3v'
let g:airline_section_warning = ''
@ -82,3 +85,20 @@ map <silent> <leader>lf :lua vim.lsp.buf.formatting()<cr>
let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.erb,*.jsx,*.tsx"
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx,*.tsx,*.erb'
" gray
highlight! CmpItemAbbrDeprecated guibg=NONE gui=strikethrough guifg=#808080
" blue
highlight! CmpItemAbbrMatch guibg=NONE guifg=#569CD6
highlight! CmpItemAbbrMatchFuzzy guibg=NONE guifg=#569CD6
" light blue
highlight! CmpItemKindVariable guibg=NONE guifg=#9CDCFE
highlight! CmpItemKindInterface guibg=NONE guifg=#9CDCFE
highlight! CmpItemKindText guibg=NONE guifg=#9CDCFE
" pink
highlight! CmpItemKindFunction guibg=NONE guifg=#C586C0
highlight! CmpItemKindMethod guibg=NONE guifg=#C586C0
" front
highlight! CmpItemKindKeyword guibg=NONE guifg=#D4D4D4
highlight! CmpItemKindProperty guibg=NONE guifg=#D4D4D4
highlight! CmpItemKindUnit guibg=NONE guifg=#D4D4D4

View File

@ -8,12 +8,13 @@ require('packer').startup(function()
use 'wbthomason/packer.nvim'
use 'gruvbox-community/gruvbox'
use 'tomasiser/vim-code-dark'
use 'bling/vim-airline'
use 'Raimondi/delimitMate'
use 'alvan/vim-closetag'
use 'scrooloose/nerdtree'
-- use 'tomtom/tcomment_vim'
-- -- use 'tomtom/tcomment_vim'
use 'tpope/vim-commentary'
use 'tpope/vim-surround'
use 'christoomey/vim-tmux-navigator'
@ -23,23 +24,26 @@ require('packer').startup(function()
-- use { 'junegunn/fzf', run = './install --bin' }
-- use 'junegunn/fzf.vim'
-- use 'tpope/vim-fugitive'
use 'ConradIrwin/vim-bracketed-paste'
-- use 'ConradIrwin/vim-bracketed-paste'
use {
'nvim-telescope/telescope.nvim',
requires = { {'nvim-lua/plenary.nvim'} }
}
use 'neovim/nvim-lspconfig' -- Collection of configurations for built-in LSP client
use 'hrsh7th/nvim-cmp' -- Autocompletion plugin
use 'hrsh7th/cmp-nvim-lsp' -- LSP source for nvim-cmp
use 'hrsh7th/cmp-buffer' -- LSP source for buffer
use 'saadparwaiz1/cmp_luasnip' -- Snippets source for nvim-cmp
use 'L3MON4D3/LuaSnip' -- Snippets plugin
-- use 'ray-x/lsp_signature.nvim'
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'
use 'onsails/lspkind-nvim'
use 'hrsh7th/cmp-vsnip'
use 'hrsh7th/vim-vsnip'
use "rafamadriz/friendly-snippets"
use 'leafgarland/typescript-vim'
use 'peitalin/vim-jsx-typescript'
use 'cespare/vim-toml'
end)
--Remap for dealing with word wrap
@ -48,6 +52,74 @@ vim.api.nvim_set_keymap('n', 'j', "v:count == 0 ? 'gj' : 'j'", { noremap = true,
require('telescope').setup{ defaults = { file_ignore_patterns = { "node_module" } } }
-- nvim-cmp setup
local cmp = require 'cmp'
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
end
cmp.setup {
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<CR>'] = cmp.mapping.confirm({ select = true }), -- 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()
elseif vim.fn["vsnip#available"](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
elseif has_words_before() then
cmp.complete()
else
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, { "i", "s" }),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' }, -- For vsnip users.
}, {
{ name = 'buffer' },
})
}
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
-- lsp setup
local nvim_lsp = require('lspconfig')
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
@ -93,11 +165,12 @@ augroup LSPDiagnosticsOnHover
augroup END
]]
vim.cmd [[autocmd CursorHoldI * lua vim.lsp.buf.signature_help()]]
vim.cmd [[autocmd CursorHoldI * silent! lua vim.lsp.buf.signature_help()]]
-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
capabilities.textDocument.completion.completionItem.snippetSupport = true
local servers = { 'clangd', 'tsserver', 'gopls', 'pylsp' }
for _, lsp in ipairs(servers) do
@ -107,6 +180,30 @@ for _, lsp in ipairs(servers) do
}
end
nvim_lsp.cssls.setup {
capabilities = capabilities,
cmd = {"vscode-css-languageserver", "--stdio"}
}
local lspkind = require('lspkind')
cmp.setup {
formatting = {
format = lspkind.cmp_format({
with_text = true,
menu = ({
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
luasnip = "[LuaSnip]",
nvim_lua = "[Lua]",
latex_symbols = "[Latex]",
})
}),
},
experimental = {
ghost_text = true
}
}
vim.fn.sign_define("LspDiagnosticsSignError", { text="" })
vim.fn.sign_define("LspDiagnosticsSignWarning", { text="" })
vim.fn.sign_define("LspDiagnosticsSignInformation", { text="" })
@ -114,51 +211,3 @@ vim.fn.sign_define("LspDiagnosticsSignHint", { text="" })
-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'
-- luasnip setup
local luasnip = require 'luasnip'
-- nvim-cmp setup
local cmp = require 'cmp'
cmp.setup {
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = {
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end,
['<S-Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end,
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'buffer' },
},
}

View File

@ -57,7 +57,7 @@ end
time([[Luarocks path setup]], false)
time([[try_loadstring definition]], true)
local function try_loadstring(s, component, name)
local success, result = pcall(loadstring(s))
local success, result = pcall(loadstring(s), name, _G.packer_plugins[name])
if not success then
vim.schedule(function()
vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {})
@ -69,105 +69,140 @@ end
time([[try_loadstring definition]], false)
time([[Defining packer_plugins]], true)
_G.packer_plugins = {
LuaSnip = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/LuaSnip"
},
["cmp-buffer"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/cmp-buffer"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/cmp-buffer",
url = "https://github.com/hrsh7th/cmp-buffer"
},
["cmp-cmdline"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/cmp-cmdline",
url = "https://github.com/hrsh7th/cmp-cmdline"
},
["cmp-nvim-lsp"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp",
url = "https://github.com/hrsh7th/cmp-nvim-lsp"
},
cmp_luasnip = {
["cmp-path"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/cmp_luasnip"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/cmp-path",
url = "https://github.com/hrsh7th/cmp-path"
},
["cmp-vsnip"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/cmp-vsnip",
url = "https://github.com/hrsh7th/cmp-vsnip"
},
delimitMate = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/delimitMate"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/delimitMate",
url = "https://github.com/Raimondi/delimitMate"
},
["friendly-snippets"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/friendly-snippets",
url = "https://github.com/rafamadriz/friendly-snippets"
},
gruvbox = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/gruvbox"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/gruvbox",
url = "https://github.com/gruvbox-community/gruvbox"
},
["lsp_signature.nvim"] = {
["lspkind-nvim"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/lsp_signature.nvim"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/lspkind-nvim",
url = "https://github.com/onsails/lspkind-nvim"
},
nerdtree = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/nerdtree"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/nerdtree",
url = "https://github.com/scrooloose/nerdtree"
},
["nvim-cmp"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-cmp"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-cmp",
url = "https://github.com/hrsh7th/nvim-cmp"
},
["nvim-lspconfig"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-lspconfig"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
url = "https://github.com/neovim/nvim-lspconfig"
},
["packer.nvim"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/packer.nvim"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/packer.nvim",
url = "https://github.com/wbthomason/packer.nvim"
},
["plenary.nvim"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/plenary.nvim"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/plenary.nvim",
url = "https://github.com/nvim-lua/plenary.nvim"
},
["telescope.nvim"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/telescope.nvim"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/telescope.nvim",
url = "https://github.com/nvim-telescope/telescope.nvim"
},
["typescript-vim"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/typescript-vim"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/typescript-vim",
url = "https://github.com/leafgarland/typescript-vim"
},
["vim-airline"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-airline"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-airline",
url = "https://github.com/bling/vim-airline"
},
["vim-bbye"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-bbye"
},
["vim-bracketed-paste"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-bracketed-paste"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-bbye",
url = "https://github.com/moll/vim-bbye"
},
["vim-closetag"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-closetag"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-closetag",
url = "https://github.com/alvan/vim-closetag"
},
["vim-code-dark"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-code-dark",
url = "https://github.com/tomasiser/vim-code-dark"
},
["vim-commentary"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-commentary"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-commentary",
url = "https://github.com/tpope/vim-commentary"
},
["vim-dispatch"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-dispatch"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-dispatch",
url = "https://github.com/tpope/vim-dispatch"
},
["vim-jsx-typescript"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-jsx-typescript"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-jsx-typescript",
url = "https://github.com/peitalin/vim-jsx-typescript"
},
["vim-surround"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-surround"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-surround",
url = "https://github.com/tpope/vim-surround"
},
["vim-tmux-navigator"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-tmux-navigator"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-tmux-navigator",
url = "https://github.com/christoomey/vim-tmux-navigator"
},
["vim-togglelist"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-togglelist"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-togglelist",
url = "https://github.com/milkypostman/vim-togglelist"
},
["vim-toml"] = {
["vim-vsnip"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-toml"
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-vsnip",
url = "https://github.com/hrsh7th/vim-vsnip"
}
}

View File

@ -1,4 +1,4 @@
_docker_subcommands=( ${(Q)"${(z)$(<<\EO:_docker_subcommands
'builder:Manage builds' 'buildx*:Build with BuildKit (Docker Inc., v0.6.1-docker)' 'compose*:Docker Compose (Docker Inc., 2.2.0)' 'config:Manage Docker configs' 'container:Manage containers' 'context:Manage contexts' 'image:Manage images' 'manifest:Manage Docker image manifests and manifest lists' 'network:Manage networks' 'node:Manage Swarm nodes' 'plugin:Manage plugins' 'secret:Manage Docker secrets' 'service:Manage services' 'stack:Manage Docker stacks' 'swarm:Manage Swarm' 'system:Manage Docker' 'trust:Manage trust on Docker images' 'volume:Manage volumes' 'attach:Attach local standard input, output, and error streams to a running container' 'build:Build an image from a Dockerfile' 'commit:Create a new image from a container''s changes' 'cp:Copy files/folders between a container and the local filesystem' 'create:Create a new container' 'diff:Inspect changes to files or directories on a container''s filesystem' 'events:Get real time events from the server' 'exec:Run a command in a running container' 'export:Export a container''s filesystem as a tar archive' 'history:Show the history of an image' 'images:List images' 'import:Import the contents from a tarball to create a filesystem image' 'info:Display system-wide information' 'inspect:Return low-level information on Docker objects' 'kill:Kill one or more running containers' 'load:Load an image from a tar archive or STDIN' 'login:Log in to a Docker registry' 'logout:Log out from a Docker registry' 'logs:Fetch the logs of a container' 'pause:Pause all processes within one or more containers' 'port:List port mappings or a specific mapping for the container' 'ps:List containers' 'pull:Pull an image or a repository from a registry' 'push:Push an image or a repository to a registry' 'rename:Rename a container' 'restart:Restart one or more containers' 'rm:Remove one or more containers' 'rmi:Remove one or more images' 'run:Run a command in a new container' 'save:Save one or more images to a tar archive (streamed to STDOUT by default)' 'search:Search the Docker Hub for images' 'start:Start one or more stopped containers' 'stats:Display a live stream of container(s) resource usage statistics' 'stop:Stop one or more running containers' 'tag:Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE' 'top:Display the running processes of a container' 'unpause:Unpause all processes within one or more containers' 'update:Update configuration of one or more containers' 'version:Show the Docker version information' 'wait:Block until one or more containers stop, then print their exit codes' 'daemon:Enable daemon mode' 'help:Show help for a command'
'builder:Manage builds' 'buildx*:Docker Buildx (Docker Inc., v0.7.1-docker)' 'compose*:Docker Compose (Docker Inc., 2.2.2)' 'config:Manage Docker configs' 'container:Manage containers' 'context:Manage contexts' 'image:Manage images' 'manifest:Manage Docker image manifests and manifest lists' 'network:Manage networks' 'node:Manage Swarm nodes' 'plugin:Manage plugins' 'secret:Manage Docker secrets' 'service:Manage services' 'stack:Manage Docker stacks' 'swarm:Manage Swarm' 'system:Manage Docker' 'trust:Manage trust on Docker images' 'volume:Manage volumes' 'attach:Attach local standard input, output, and error streams to a running container' 'build:Build an image from a Dockerfile' 'commit:Create a new image from a container''s changes' 'cp:Copy files/folders between a container and the local filesystem' 'create:Create a new container' 'diff:Inspect changes to files or directories on a container''s filesystem' 'events:Get real time events from the server' 'exec:Run a command in a running container' 'export:Export a container''s filesystem as a tar archive' 'history:Show the history of an image' 'images:List images' 'import:Import the contents from a tarball to create a filesystem image' 'info:Display system-wide information' 'inspect:Return low-level information on Docker objects' 'kill:Kill one or more running containers' 'load:Load an image from a tar archive or STDIN' 'login:Log in to a Docker registry' 'logout:Log out from a Docker registry' 'logs:Fetch the logs of a container' 'pause:Pause all processes within one or more containers' 'port:List port mappings or a specific mapping for the container' 'ps:List containers' 'pull:Pull an image or a repository from a registry' 'push:Push an image or a repository to a registry' 'rename:Rename a container' 'restart:Restart one or more containers' 'rm:Remove one or more containers' 'rmi:Remove one or more images' 'run:Run a command in a new container' 'save:Save one or more images to a tar archive (streamed to STDOUT by default)' 'search:Search the Docker Hub for images' 'start:Start one or more stopped containers' 'stats:Display a live stream of container(s) resource usage statistics' 'stop:Stop one or more running containers' 'tag:Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE' 'top:Display the running processes of a container' 'unpause:Unpause all processes within one or more containers' 'update:Update configuration of one or more containers' 'version:Show the Docker version information' 'wait:Block until one or more containers stop, then print their exit codes' 'daemon:Enable daemon mode' 'help:Show help for a command'
EO:_docker_subcommands
)}"} )