Skip to content

Instantly share code, notes, and snippets.

@pigeonhands
Last active November 20, 2022 23:47
Show Gist options
  • Save pigeonhands/478508798d4d02e10b0304face78962d to your computer and use it in GitHub Desktop.
Save pigeonhands/478508798d4d02e10b0304face78962d to your computer and use it in GitHub Desktop.
nvim, alacritty configurations
font:
size: 10.0
normal:
family: Hack NF
style: Regular
bold:
family: Hack NF
style: Bold
italic:
family: Hack NF
style: Italic
bold_italic:
family: Hack NF
style: Bold Italic
colors:
# Default colors
primary:
background: '0x292d3e'
foreground: '0x959dcb'
# Colors the cursor will use if `custom_cursor_colors` is true
cursor:
text: '0x292d3e'
cursor: '0x959dcb'
# Normal colors
normal:
black: '0x292d3e'
red: '0xf07178'
green: '0xc3e88d'
yellow: '0xffcb6b'
blue: '0x82aaff'
magenta: '0xc792ea'
cyan: '0x89ddff'
white: '0x959dcb'
# Bright colors
bright:
black: '0x676e95'
red: '0xf07178'
green: '0xc3e88d'
yellow: '0xffcb6b'
blue: '0x82aaff'
magenta: '0xc792ea'
cyan: '0x89ddff'
white: '0xffffff'
indexed_colors:
- { index: 16, color: '0xf78c6c' }
- { index: 17, color: '0xff5370' }
- { index: 18, color: '0x444267' }
- { index: 19, color: '0x32374d' }
- { index: 20, color: '0x8796b0' }
- { index: 21, color: '0x959dcb' }
-- %LOCALAPPDATA%\nvim\init.lua
vim.wo.number = true
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.keymap.set('n', '<C-H>', ':bprev<CR>')
vim.keymap.set('n', '<C-L>', ':bnext<CR>')
vim.keymap.set('n', '<C-p>', require('telescope.builtin').find_files)
vim.keymap.set('n', '<C-d>', require("nvim-tree").toggle)
local use = require('packer').use
require('packer').startup(function()
use 'wbthomason/packer.nvim' -- Package manager
use {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"neovim/nvim-lspconfig",
}
use 'simrat39/rust-tools.nvim'
-- Debugging
use 'nvim-lua/plenary.nvim'
use 'mfussenegger/nvim-dap'
use { 'nvim-treesitter/nvim-treesitter' }
use {
"SmiteshP/nvim-navic",
requires = "neovim/nvim-lspconfig"
}
use {'akinsho/bufferline.nvim', tag = "v3.*", requires = 'nvim-tree/nvim-web-devicons'}
use {
'nvim-tree/nvim-tree.lua',
requires = {
'nvim-tree/nvim-web-devicons', -- optional, for file icons
}
}
use 'machakann/vim-highlightedyank'
--use { 'junegunn/fzf', run = ":call fzf#install()" }
--use { 'junegunn/fzf.vim' }
use 'mhinz/vim-startify'
use 'tpope/vim-surround' -- (o_o) -> ca([ -> [o_o]
use 'jiangmiao/auto-pairs'
use 'stevearc/dressing.nvim'
use 'ryanoasis/vim-devicons'
use {
'nvim-telescope/telescope.nvim', tag = '0.1.0',
requires = { {'nvim-lua/plenary.nvim'} }
}
use { -- Telescope fie browser
'nvim-telescope/telescope-file-browser.nvim',
}
use("arcticicestudio/nord-vim")
use {
"folke/trouble.nvim",
requires = "kyazdani42/nvim-web-devicons",
config = function()
require("trouble").setup {
-- your configuration comes here
-- or leave it empty to use the default settings
}
end
}
-- LSP loading status
use({
"j-hui/fidget.nvim",
config = function()
require("fidget").setup()
end
})
use("hrsh7th/nvim-cmp")
use({"L3MON4D3/LuaSnip", tag = "v1.*"})
use({
-- cmp LSP completion
"hrsh7th/cmp-nvim-lsp",
-- cmp Snippet completion
--"hrsh7th/cmp-vsnip",
-- cmp Path completion
"hrsh7th/cmp-path",
"hrsh7th/cmp-buffer",
after = { "hrsh7th/nvim-cmp" },
requires = { "hrsh7th/nvim-cmp" },
})
use("nvim-lua/popup.nvim")
use 'RRethy/vim-illuminate'
use {
'saecki/crates.nvim',
tag = 'v0.3.0',
requires = { 'nvim-lua/plenary.nvim' },
config = function()
require('crates').setup()
end,
}
--use({
-- "glepnir/lspsaga.nvim",
-- branch = "main"
-- })
end)
require("nvim-tree").setup()
vim.o.completeopt = "menuone,noinsert,noselect"
vim.opt.shortmess = vim.opt.shortmess + "c"
vim.opt.termguicolors = true
require("bufferline").setup{
options = {
seperator_stype = 'padded_slant'
}
}
vim.cmd 'colorscheme nord'
vim.g.material_style = "deep ocean"
require("mason").setup()
require("mason-lspconfig").setup()
local function on_attach(client, buffer)
local keymap_opts = { buffer = buffer }
-- Code navigation and shortcuts
vim.keymap.set("n", "<c-]>", vim.lsp.buf.definition, keymap_opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, keymap_opts)
vim.keymap.set("n", "gD", vim.lsp.buf.implementation, keymap_opts)
vim.keymap.set("n", "<c-k>", vim.lsp.buf.signature_help, keymap_opts)
vim.keymap.set("n", "1gD", vim.lsp.buf.type_definition, keymap_opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, keymap_opts)
vim.keymap.set("n", "g0", vim.lsp.buf.document_symbol, keymap_opts)
vim.keymap.set("n", "gW", vim.lsp.buf.workspace_symbol, keymap_opts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, keymap_opts)
vim.keymap.set("n", "ga", vim.lsp.buf.code_action, keymap_opts)
-- Set updatetime for CursorHold
-- 300ms of no cursor movement to trigger CursorHold
vim.opt.updatetime = 100
-- Show diagnostic popup on cursor hover
local diag_float_grp = vim.api.nvim_create_augroup("DiagnosticFloat", { clear = true })
vim.api.nvim_create_autocmd("CursorHold", {
callback = function()
vim.diagnostic.open_float(nil, { focusable = false })
end,
group = diag_float_grp,
})
-- Goto previous/next diagnostic warning/error
vim.keymap.set("n", "g[", vim.diagnostic.goto_prev, keymap_opts)
vim.keymap.set("n", "g]", vim.diagnostic.goto_next, keymap_opts)
end
-- Configure LSP through rust-tools.nvim plugin.
-- rust-tools will configure and enable certain LSP features for us.
-- See https://github.com/simrat39/rust-tools.nvim#configuration
local opts = {
tools = {
runnables = {
use_telescope = true,
},
inlay_hints = {
auto = true,
show_parameter_hints = false,
parameter_hints_prefix = "",
other_hints_prefix = "",
},
},
server = {
on_attach = on_attach,
settings = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy",
},
},
},
},
}
require("rust-tools").setup(opts)
local cmp = require("cmp")
cmp.setup({
preselect = cmp.PreselectMode.None,
snippet = {
expand = function(args)
--vim.fn["vsnip#anonymous"](args.body)
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
end,
},
mapping = {
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-n>"] = cmp.mapping.select_next_item(),
-- Add tab support
["<S-Tab>"] = cmp.mapping.select_prev_item(),
["<Tab>"] = 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.Insert,
select = true,
}),
},
-- Installed sources
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "path" },
{ name = "buffer" },
{ name = "crates" },
},
})
" ~/.config/nvim/init.vim
set nu
set relativenumber
set encoding=UTF-8
set tabstop=4
set shiftwidth=4
set expandtab
set undodir=~/.vimdid
set undofile
set grepprg=rg\ --vimgrep
set mouse=a
set hidden
set signcolumn=yes
filetype plugin indent on
map <C-H> :bprev<CR>
map <C-L> :bnext<CR>
map <C-T>c :bd<CR>
nnoremap <Leader>rg :Rg<Space>
nmap <C-P> :FZF<CR>
nmap <C-D> :NERDTreeToggle<CR>
tnoremap <Esc> <C-\><C-n>
" Coc bindings
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
nmap <leader>rn <Plug>(coc-rename)
autocmd CursorHold * silent call CocActionAsync('highlight')
nnoremap <silent> K :call <SID>show_documentation()<CR>
inoremap <silent><expr> <c-space> coc#refresh()
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)
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
call plug#begin('~/.config/nvim/plugged')
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
Plug 'vim-airline/vim-airline'
Plug 'scrooloose/nerdtree'
Plug 'machakann/vim-highlightedyank'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
" Plug 'lotabout/skim', { 'dir': '~/.skim', 'do': './install' }
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'cespare/vim-toml'
Plug 'vifm/vifm.vim'
Plug 'mhinz/vim-startify'
"Plug 'bagrat/vim-buffet'
Plug 'sheerun/vim-polyglot'
" Plug 'chriskempson/base16-vim'
" Plug 'Badacadabra/vim-archery'
" Plug 'danilo-augusto/vim-afterglow'
Plug 'sainnhe/sonokai'
Plug 'ryanoasis/vim-devicons'
call plug#end()
if has('termguicolors')
set termguicolors
endif
let g:airline#extensions#tabline#enabled = 0
let g:sonokai_transparent_background = 1
let g:sonokai_style = 'maia'
let g:sonokai_enable_italic = 1
let g:sonokai_disable_italic_comment = 1
colorscheme sonokai
let g:airline_theme = 'sonokai'
let g:airline_powerline_fonts=1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#show_splits = 1
let g:airline#extensions#tabline#show_buffers = 1
let g:airline#extensions#coc#enabled = 1
" colorscheme base16-material-palenight
let g:webdevicons_enable_startify = 1
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
function! s:GoToDefinition()
if CocAction('jumpDefinition')
return v:true
endif
let ret = execute("silent! normal \<C-]>")
if ret =~ "Error" || ret =~ "错误"
call searchdecl(expand('<cword>'))
endif
endfunction
" --column: Show column number
" --line-number: Show line number
" --no-heading: Do not show file headings in results
" --fixed-strings: Search term as a literal string
" --ignore-case: Case insensitive search
" --no-ignore: Do not respect .gitignore, etc...
" --hidden: Search hidden files and folders
" --follow: Follow symlinks
" --glob: Additional conditions for search (in this case ignore everything in the .git/ folder)
" --color: Search color options
" command! -bang -nargs=* Rg call fzf#vim#rg_interactive(<q-args>, fzf#vim#with_preview('right:50%:hidden', 'alt-h'))
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --no-ignore --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>), 1, <bang>0)
command! -nargs=0 Prettier :CocCommand prettier.formatFile
// This file was initially generated by Windows Terminal 1.0.1811.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{2c4de342-38b7-51cf-b940-2309a097f518}",
// You can add more global application settings here.
// To learn more about global settings, visit https://aka.ms/terminal-global-settings
// If enabled, selections are automatically copied to your clipboard.
"copyOnSelect": false,
// If enabled, formatted data is also copied to your clipboard
"copyFormatting": false,
// A profile specifies a command to execute paired with information about how it should look and feel.
// Each one of them will appear in the 'New Tab' dropdown,
// and can be invoked from the commandline with `wt.exe -p xxx`
// To learn more about profiles, visit https://aka.ms/terminal-profile-settings
"profiles": {
"defaults": {
// Put settings here that you want to apply to all profiles.
"colorScheme": "Material Palenight",
"fontFace": "Hack NF",
"fontSize": 11
},
"list": [
{
// Make changes here to the powershell.exe profile.
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false,
},
{
// Make changes here to the cmd.exe profile.
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "Command Prompt",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure",
},
{
"guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"hidden": false,
"name": "Ubuntu",
"source": "Windows.Terminal.Wsl"
}
]
},
// Add custom color schemes to this array.
// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
"schemes": [
{
"name": "Material Palenight",
"background": "#292d3e",
"foreground": "#959dcb",
"black": "#292D3E",
"red": "#F07178",
"green": "#C3E88D",
"yellow": "#FFCB6B",
"blue": "#82AAFF",
"purple": "#C792EA",
"cyan": "#89DDFF",
"white": "#959DCB",
"brightBlack": "#676E95",
"brightRed": "#F78C6C",
"brightGreen": "#444267",
"brightYellow": "#32374D",
"brightBlue": "#8796B0",
"brightPurple": "#959DCB",
"brightCyan": "#FF5370",
"brightWhite": "#FFFFFF"
}
],
// Add custom keybindings to this array.
// To unbind a key combination from your defaults.json, set the command to "unbound".
// To learn more about keybindings, visit https://aka.ms/terminal-keybindings
"keybindings": [
// Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
// These two lines additionally bind them to Ctrl+C and Ctrl+V.
// To learn more about selection, visit https://aka.ms/terminal-selection
{
"command": {
"action": "copy",
"singleLine": false
},
"keys": "ctrl+c"
},
{
"command": "paste",
"keys": "ctrl+v"
},
// Press Ctrl+Shift+F to open the search box
{
"command": "find",
"keys": "ctrl+shift+f"
},
// Press Alt+Shift+D to open a new pane.
// - "split": "auto" makes this pane open in the direction that provides the most surface area.
// - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
// To learn more about panes, visit https://aka.ms/terminal-panes
{
"command": {
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"keys": "alt+shift+d"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment