mirror of
				https://github.com/tiyn/wiki.git
				synced 2025-11-04 04:11:15 +01:00 
			
		
		
		
	linux/vim: removed vim coc due to being outdated
This commit is contained in:
		@@ -1,40 +0,0 @@
 | 
				
			|||||||
# C in Vim
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
C is a common programming language.
 | 
					 | 
				
			||||||
In this article we will focus on making vim support c and use vim as an ide for
 | 
					 | 
				
			||||||
c.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Autocompletion
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### Coc
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
To enable autocompletion for [coc](coc.md) you need to install `ccls`.
 | 
					 | 
				
			||||||
After that you need to add the following lines to your coc config file.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
```json
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   "languageserver": {
 | 
					 | 
				
			||||||
       "ccls": {
 | 
					 | 
				
			||||||
           "command": "ccls",
 | 
					 | 
				
			||||||
           "filetypes": [
 | 
					 | 
				
			||||||
               "c",
 | 
					 | 
				
			||||||
               "cpp",
 | 
					 | 
				
			||||||
               "objc",
 | 
					 | 
				
			||||||
               "objcpp"
 | 
					 | 
				
			||||||
           ],
 | 
					 | 
				
			||||||
           "rootPatterns": [
 | 
					 | 
				
			||||||
               ".ccls",
 | 
					 | 
				
			||||||
               "compile_commands.json",
 | 
					 | 
				
			||||||
               ".vim/",
 | 
					 | 
				
			||||||
               ".git/",
 | 
					 | 
				
			||||||
               ".hg/"
 | 
					 | 
				
			||||||
           ],
 | 
					 | 
				
			||||||
           "initializationOptions": {
 | 
					 | 
				
			||||||
               "cache": {
 | 
					 | 
				
			||||||
                   "diretory": "/tmp/ccls"
 | 
					 | 
				
			||||||
               }
 | 
					 | 
				
			||||||
           }
 | 
					 | 
				
			||||||
       }
 | 
					 | 
				
			||||||
   }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
@@ -1,82 +0,0 @@
 | 
				
			|||||||
# Coc in Vim
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[Conquer of completion](https://github.com/neoclide/coc.nvim) enables full
 | 
					 | 
				
			||||||
language server protocol support for neovim.
 | 
					 | 
				
			||||||
It is written specifically for neovim.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The coc config file is located in `.config/nvim/coc-settings.json`.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Installation
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- Install `nodejs`
 | 
					 | 
				
			||||||
- Install [vim-plug](vim-plug.md)
 | 
					 | 
				
			||||||
- Add coc.vim to your init.vim
 | 
					 | 
				
			||||||
  - Add `Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'}`
 | 
					 | 
				
			||||||
  to your Plug-Section
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Base config
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Add the base configuration to your vim config file.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
```vimscript
 | 
					 | 
				
			||||||
" neoclide/coc.nvim
 | 
					 | 
				
			||||||
inoremap <silent><expr> <TAB>
 | 
					 | 
				
			||||||
      \ pumvisible() ? "\<C-n>" :
 | 
					 | 
				
			||||||
      \ <SID>check_back_space() ? "\<TAB>" :
 | 
					 | 
				
			||||||
      \ coc#refresh()
 | 
					 | 
				
			||||||
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function! s:check_back_space() abort
 | 
					 | 
				
			||||||
  let col = col('.') - 1
 | 
					 | 
				
			||||||
  return !col || getline('.')[col - 1]  =~# '\s'
 | 
					 | 
				
			||||||
endfunction
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if has('nvim')
 | 
					 | 
				
			||||||
  inoremap <silent><expr> <c-space> coc#refresh()
 | 
					 | 
				
			||||||
else
 | 
					 | 
				
			||||||
  inoremap <silent><expr> <c-@> coc#refresh()
 | 
					 | 
				
			||||||
endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
 | 
					 | 
				
			||||||
                              \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
nmap <silent> gd <Plug>(coc-definition)
 | 
					 | 
				
			||||||
nmap <silent> gy <Plug>(coc-type-definition)
 | 
					 | 
				
			||||||
nmap <silent> gi <Plug>(coc-implementation)
 | 
					 | 
				
			||||||
nmap <silent> gr <Plug>(coc-references)
 | 
					 | 
				
			||||||
nnoremap <silent> K :call <SID>show_documentation()<CR>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function! s:show_documentation()
 | 
					 | 
				
			||||||
  if (index(['vim','help'], &filetype) >= 0)
 | 
					 | 
				
			||||||
    execute 'h '.expand('<cword>')
 | 
					 | 
				
			||||||
  elseif (coc#rpc#ready())
 | 
					 | 
				
			||||||
    call CocActionAsync('doHover')
 | 
					 | 
				
			||||||
  else
 | 
					 | 
				
			||||||
    execute '!' . &keywordprg . " " . expand('<cword>')
 | 
					 | 
				
			||||||
  endif
 | 
					 | 
				
			||||||
endfunction
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
autocmd CursorHold * silent call CocActionAsync('highlight')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
nmap <F5> <Plug>(coc-rename)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
xmap <leader>f  <Plug>(coc-format-selected)
 | 
					 | 
				
			||||||
nmap <leader>f  <Plug>(coc-format-selected)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
augroup mygroup
 | 
					 | 
				
			||||||
  autocmd!
 | 
					 | 
				
			||||||
  autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
 | 
					 | 
				
			||||||
  autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
 | 
					 | 
				
			||||||
augroup end
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Extensions
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Extensions can be added to the vim config aswell.
 | 
					 | 
				
			||||||
A basic example for adding a few extensions is:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
```vimscript
 | 
					 | 
				
			||||||
let g:coc_global_extensions = [
 | 
					 | 
				
			||||||
    \ ]
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@@ -1,43 +0,0 @@
 | 
				
			|||||||
# GoLang in Vim
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
GoLang is a common programming language.
 | 
					 | 
				
			||||||
In this article we will focus on making vim support Go and use vim as an ide
 | 
					 | 
				
			||||||
for it.
 | 
					 | 
				
			||||||
This guide is based on a guide from
 | 
					 | 
				
			||||||
[octetz.com](https://octetz.com/docs/2019/2019-04-24-vim-as-a-go-ide/).
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Build, Test, Run, Docs, Debug, Format
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
To enable most of the basic functions of an IDE you need to install `vim-go` via
 | 
					 | 
				
			||||||
`vim plug`.
 | 
					 | 
				
			||||||
For this add `Plug 'fatih/vim-go' " better support for golang` in your plug section
 | 
					 | 
				
			||||||
in the `init.vim` file.
 | 
					 | 
				
			||||||
Then run `:PlugInstall` and `:GoInstallBinaries` inside `nvim`.
 | 
					 | 
				
			||||||
Finally add `let g:go_def_mapping_enabled = 0` to your `init.vim` to make sure
 | 
					 | 
				
			||||||
the mapping `gd` will be used by `coc` and its language server.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Autocompletion
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### Coc
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
To enable autocompletion for [coc](coc.md) you need to install `ccls`.
 | 
					 | 
				
			||||||
After that you need to add the following lines to your coc config file.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
```json
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   "languageserver": {
 | 
					 | 
				
			||||||
        "golang": {
 | 
					 | 
				
			||||||
            "command": "gopls",
 | 
					 | 
				
			||||||
            "rootPatterns": [
 | 
					 | 
				
			||||||
                "go.mod",
 | 
					 | 
				
			||||||
                ".vim/",
 | 
					 | 
				
			||||||
                ".git/",
 | 
					 | 
				
			||||||
                ".hg/"
 | 
					 | 
				
			||||||
            ],
 | 
					 | 
				
			||||||
            "filetypes": [
 | 
					 | 
				
			||||||
                "go"
 | 
					 | 
				
			||||||
            ]
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
   }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
@@ -1,28 +0,0 @@
 | 
				
			|||||||
# Nim in Vim
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[Nim](https://nim-lang.org) is a statically typed compiled systems programming.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Autocompletion
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### Coc
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
To enable autocompletion for [coc](coc.md) you need to install `nimlsp`
 | 
					 | 
				
			||||||
(`nimble install nimlsp`).
 | 
					 | 
				
			||||||
After that you need to add the following lines to your coc config file.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
```json
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    "languageserver": {
 | 
					 | 
				
			||||||
        "nim": {
 | 
					 | 
				
			||||||
            "command": "nimlsp",
 | 
					 | 
				
			||||||
            "filetypes": ["nim"],
 | 
					 | 
				
			||||||
            "trace.server": "verbose"
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
   }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### Highlighting
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
To enable highlighting you can install a
 | 
					 | 
				
			||||||
[vim plugin by zah](https://github.com/zah/nim.vim).
 | 
					 | 
				
			||||||
@@ -1,24 +0,0 @@
 | 
				
			|||||||
# Python in Vim
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Python is a common programming language.
 | 
					 | 
				
			||||||
In this article we will focus on making vim support python and use vim as an
 | 
					 | 
				
			||||||
ide for it.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Autocompletion
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### Coc
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
To enable autocompletion for [coc](coc.md) you need to install the coc-package
 | 
					 | 
				
			||||||
`coc-python`. Do that by adding it to the extension section of your `init.vim`.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Formatting
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Install `autopep8` to your system.
 | 
					 | 
				
			||||||
Then add `autocmd FileType python setlocal formatprg=autopep8\ -` and
 | 
					 | 
				
			||||||
`autocmd FileType python noremap <F8> gggqG` to your
 | 
					 | 
				
			||||||
`init.vim` to reformat on F8.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Line length
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
To set your python buffers to show column 80 add
 | 
					 | 
				
			||||||
`autocmd BufEnter,FileType python set colorcolumn=80` to your `init.vim`.
 | 
					 | 
				
			||||||
@@ -1,28 +0,0 @@
 | 
				
			|||||||
# VHDL in Vim
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
VHDL is a hardware description language.
 | 
					 | 
				
			||||||
In this article we will focus on making vim support VHDL.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Linting
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### Coc
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
To enable linting and other language server features for [coc](coc.md) you need
 | 
					 | 
				
			||||||
to install [hdl-checker](https://github.com/suoto/hdl_checker).
 | 
					 | 
				
			||||||
After that you need to add the following lines to your coc config file.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
```json
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    "hdlChecker": {
 | 
					 | 
				
			||||||
        "command": "hdl_checker",
 | 
					 | 
				
			||||||
        "args": [
 | 
					 | 
				
			||||||
            "--lsp"
 | 
					 | 
				
			||||||
        ],
 | 
					 | 
				
			||||||
        "filetypes": [
 | 
					 | 
				
			||||||
            "vhdl",
 | 
					 | 
				
			||||||
            "verilog",
 | 
					 | 
				
			||||||
            "systemverilog"
 | 
					 | 
				
			||||||
        ]
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
@@ -1,35 +0,0 @@
 | 
				
			|||||||
# Vim-Plug
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[Vim-Plug](https://github.com/junegunn/vim-plug) is a minimalist plugin manager.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Installation
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
You can add the following lines to your vim config file to make sure vim-plug is
 | 
					 | 
				
			||||||
installed with the correct folder-structure.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
```vimscript
 | 
					 | 
				
			||||||
if ! filereadable(expand('~/.config/nvim/autoload/plug.vim'))
 | 
					 | 
				
			||||||
    echo "Downloading junegunn/vim-plug to manage plugins..."
 | 
					 | 
				
			||||||
    silent !mkdir -p ~/.config/nvim/autoload/
 | 
					 | 
				
			||||||
    silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim
 | 
					 | 
				
			||||||
    autocmd VimEnter * PlugInstall
 | 
					 | 
				
			||||||
endif
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Below is an example plugin section.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
```vimscript
 | 
					 | 
				
			||||||
call plug#begin('~/.local/share/nvim/plugged')
 | 
					 | 
				
			||||||
Plug 'airblade/vim-gitgutter'
 | 
					 | 
				
			||||||
Plug 'tpope/vim-surround'
 | 
					 | 
				
			||||||
Plug 'uiiaoo/java-syntax.vim' , {'for': 'java'}
 | 
					 | 
				
			||||||
call plug#end()
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Important commands
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- `:PlugInstall` - install plugins specified in the Plug section
 | 
					 | 
				
			||||||
- `:PlugClean` - remove plugins that are not specified in the Plug section
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
For both of these command remember to write the file and reload the buffer if
 | 
					 | 
				
			||||||
you just added a new plugin or removed one.
 | 
					 | 
				
			||||||
@@ -1,22 +0,0 @@
 | 
				
			|||||||
# Vim
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[Vim](https://github.com/vim/vim) is a texteditor.
 | 
					 | 
				
			||||||
A good alternative to baseline Vim is Neovim.
 | 
					 | 
				
			||||||
[Neovim](https://github.com/neovim/neovim) is based on Vim and focused
 | 
					 | 
				
			||||||
on extensibility and usability.
 | 
					 | 
				
			||||||
The configuration file is stored in `.config/nvim/init.vim`
 | 
					 | 
				
			||||||
On GitHub [Vim-Galore](https://github.com/mhinz/vim-galore) gives extensive guides and tips on using
 | 
					 | 
				
			||||||
Vim.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Plug-In
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
There are a bunch of different options for managing plug-ins.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- [Vim-plug](vim-plug.md)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Autocompletion
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
An important feature for writing text and especially code is autocompletion.
 | 
					 | 
				
			||||||
For Neovim there are a few options.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- [Conquer of completion](coc.md)
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user