Skip to content

Smart and playful little VimSetup for WebDev ...or whatever else.

Notifications You must be signed in to change notification settings

AndiKod/racoon.vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 

Repository files navigation

                ,,,
             .'    `/\_/\
           .'       <@I@>
<((((((((((  )____(  \./
           \( \(   \(\(
            `-"`-"  " "

Your new coding pet ^^

Rac@@n.Vim, playful little VimStarter

Racoon-Vim.png

This minimal vimrc file will auto-configure Vim with some useful defaults for WebDev (but not only), and it's minimal on purpose as it's just a starting point. Make your own Rac@@n pet. It's just Vim.

Some goals for a WebDev kickstart:

  • Ease of installation
  • Handful of meaningful keybinds
  • Simple plugins management
  • Browse/Manage local files
  • Jump to specific files & more
  • Visualise opened buffers & cycle
  • Highlight webDev files + bonus
  • Format on save with Prettier
  • Live lint/hint js, css, ...
  • Autocomplete, Snippets, Emmet
  • Tabnine AI suggestions
  • Easy to run parallel shell
  • Nice looking default theme
  • Extendable to fit new needs

One file, hands-free simple Install

  1. Backup/Rename existing .vimrc and things inside .vim folder You can either have ~/.vimrc OR ~/.vim/vimrc
  2. Copy the vimrc file inside ~/.vim folder (to keep is simple)
  3. Open Vim :)

VimPlug will install itself inside .vim/autoload, then procede to install the main plugins in .vim/plugged including coc.nvim, then CocNvim will install a first round of extensions/tools/lsp:

" Auto install first extentions
let g:coc_global_extensions = [ 'coc-vimlsp', 'coc-tabnine', 'coc-snippets', 'coc-prettier', 'coc-pairs', 'coc-html', 'coc-eslint', 'coc-emmet', 'coc-tsserver', 'coc-json', 'coc-css', '@yaegassy/coc-tailwindcss3', coc-sh ]

You're ready to roll with snippets, auto completion, auto formating, AI assistant, live checking for errors, ...as a starting point. It's just a beginning.

The installed plugins and config files are in ~/.vim and ~/.config/coc/.

&:Options

General settings with sub-sections like: ::display, ::indentation, etc. See the ressources, examples and docs so you could tweek your own options if needed.

Just in case, for reminder, some general Vim Cheat-Sheet

...on devhints and quickref, the other lists around Linux commands are also gems.

&:Plugins

Managing plugins with VimPlug is as simple as that:

call plug#begin()

" List your plugins here
Plug 'tpope/vim-commentary'

call plug#end()

:Plug commands will help managing plugings, with commands such as :PlugInstall, :PlugUpdate, :PlugClean, & so on.

Here are the included, self installing plugings:

  • -- Core:
  • CocNvim : all you need for LSP & co, via extensions
  • BuffTabline : visual tabs for opened buffers
  • Vim-Airline : versatile status bar
  • FzF : fuzzy finder multi-purpose search
  • -- Plus:
  • Catppuccin : delicious colorschemes, or replace with your fav'
  • Comentary : easy comments with <gcc>
  • Fugitive : :Git inside Vim, or get Oh-My-Bash with Git plugin
  • Surround : amazing tool to get around things
  • CSS Colors : colors preview inside css files
  • -- Optional:
  • Vim-Transparent : making themes background transparent
  • Startify : custom[isable] starting page

For things specific to a language or more, I let Conquer of Completion doing the heavy lifting, while keeping the config simple and clean. Commands starting with :Coc will do a lot, with installing functionalities, using custom commands and acessing the general :CocConfig file.

There are a lot of supported languages and tools, you can add whatever you need from the list. See the coc-extentions. Others can be found directly on NPM.

Most of times, the defaults are good enough out of the box. The eventual customisations are well documented on each extention README, while Rac@@n will expand suggestions with <tab> and navigate the lists with <c-n>/<c-p> for next or previous suggestion.

&:Mappings

Here are some simple daily commands, among others:

<Esc> : Escape
<C-s> : Control + s
<Leader>e : The leader key (space in Rac@@n) + e

Binding Action
jj The other <Esc> or <C-c>
<C-s> Save the current buffer & Format
<leader>ff Find files inside the project [FzF]
<leader>sc Search in the Current buffer [FzF]
<leader>n Open a minimal Netrw, then inside:
% Create a new file
d Create a new directory
R Rename something under the cursor
D Delete what you want
- Go up one Dir/
<tab> Exit Netrw
<C-h> Navigate splits with C+h or j/k/l
<Tab> Go to next buffer. Expand/Autocomplete
<S-Tab> Go to the previous buffer in the list.
<leader>b Show the opened buffers list
<leader>x Close (delete) the current buffer
<leader>t Open an internal teminal [:term]
<leader>tv Open a terminal, Vertically
exit ...inside the terminal to close it
--- Some more ...
> or < Indent the line, and keep the selection
gcc Toggle comments [vim-Comentary]
<leader>ev Edit .vimrc or .vim/vimrc as $MYVIMRC
<leader>sv Source the $MYVIMRC file to apply changes
<Esc> Will remove the highlighted search
<leader>cx List the installed coc-extensions
<leader>s Open the Startify screen if needed

To see the rest or add yours, head to the vimrc ;) and plugins/extentions docs.


:Verbose

You already know the esential parts, yet, here's some more :)

Bash Scripting LSP

Via the awesome webinstall.dev tool, install Shellcheck and shfmt with:

curl -sS https://webi.sh/shellcheck | sh

and

curl -sS https://webi.sh/shfmt | sh

...then run :CocConfig and setup the LSP with at least:

{
  "coc.preferences.formatOnSave": true,
  "languageserver": {
    "sh": {
      "command": "shfmt",
      "args": ["-i", "2", "-ci"], // Customize your options here
      "filetypes": ["sh"],
      "initializationOptions": {},
      "settings": {}
    }
  }
}

Running :CocInstall coc-sh won't hurt, and documentation is on the coc-sh repo

Some words about NERDTree & co

Not an absolute necessity, but if you so wish add those plugins:

And a keybind mapped to :NERDTreeToggle. From within the sidebar, m will open the files operations menu.

Yet, a really powerful alternative, when it comes to visually managing files, is to get something like Yazi with that single plugin on top of it.

Autocompletion and Snippets

Comming from coc-snippets, other coc-extensions and plugins, quite some snippets are actives and <tab> will expand them, while <c-p> or <c-n> will move on the previous or next suggestion.

Say you want to add a custom snippet for .md files. From an actual markdown file, enter the command :CocCommand snippets.editSnippets. This will open the file ~/.config/coc/ultisnips/markdown.snippets with an example inside to get you started.

Easy to run parallel shell

On a personnal level, I really like WezTerm, with this setup via a simple lua file, making it beautiful and Tmux-like without complications. Short video demo, not mine, thx to the author.

Tmux can also be an option, witch don't exclude Wez. Both work great together.

Extendable to fit new needs

At the end of the day, it's just Vim. It can do anything but the coffee.


Joe is comming from here https://ascii.co.uk/art/racoon signed by ejm

About

Smart and playful little VimSetup for WebDev ...or whatever else.

Topics

Resources

Stars

Watchers

Forks