1
0
Fork 0

modified: .config/nvim/init.vim

- remove plugins ncm2, coc, ale and spaceduck colorscheme
  - revert back to colorcolumn=80
  - add auto-complete support to the Rust section
  - add plugins for Rust, auto-completion and git
  - add key bindings for auto-complete support
  - add a section to specify indent depth for different file types
  - cleanup comments that are not comments :p

modified: .zsh_aliases

  - for host bluefeds, add alias containerfreeall

added: .config/nvim/lua/*
This commit is contained in:
Pratham Patel 2022-09-24 19:33:51 +05:30
parent ae79fb8497
commit 6edbdc115e
4 changed files with 295 additions and 45 deletions

View File

@ -6,30 +6,43 @@ call plug#begin('~/.vim/plugged')
" base16 theme
Plug 'chriskempson/base16-vim'
" ncm2 (Neovim-only auto-complete)
"Plug 'roxma/nvim-yarp'
"Plug 'ncm2/ncm2'
"Plug 'ncm2/ncm2-bufword'
"Plug 'ncm2/ncm2-path'
" collection of common configurations for the Nvim LSP client
Plug 'neovim/nvim-lspconfig'
" Fuzzy finder
" auto-complete
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'
" for vsnip
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'
" fuzzy finder
Plug 'airblade/vim-rooter'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" optional
Plug 'nvim-lua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
" vim ripgrep
Plug 'jremmen/vim-ripgrep'
" .rs
" official rust plugin
Plug 'rust-lang/rust.vim'
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
"Plug 'dense-analysis/ale'
" to enable more of the features of rust-analyzer, such as inlay hints and more!
Plug 'simrat39/rust-tools.nvim'
"Plug 'wuelnerdotexe/vim-enfocado'
"Plug 'tpope/vim-fugitive'
" git wrapper
Plug 'tpope/vim-fugitive'
" src tree view
Plug 'preservim/nerdtree'
"Plug 'pineapplegiant/spaceduck'
"Plug 'pineapplegiant/spaceduck', { 'branch': 'main' }
call plug#end()
@ -40,7 +53,7 @@ call plug#end()
" dealing with files
syntax on
filetype plugin indent on
set colorcolumn=72
set colorcolumn=80
set autoindent expandtab tabstop=4 shiftwidth=4
set encoding=utf-8
@ -53,8 +66,8 @@ set spell
set termguicolors
set cursorline
let base16colorspace=256
colorscheme base16-gruvbox-dark-hard
colorscheme base16-google-dark
"colorscheme base16-gruvbox-dark-hard
"set cursorcolumn
"set clipboard=unnamed,unnamedplus
@ -82,41 +95,59 @@ set pastetoggle=<F2>
"set viminfo=
" ==============================================================================
" Auto-complete (ncm2)
" ==============================================================================
" enable ncm2 for all buffers
"autocmd BufEnter * call ncm2#enable_for_buffer()
" IMPORTANT: :help Ncm2PopupOpen for more information
"set completeopt=noinsert,menuone,noselect
" ncm2: CTRL-C doesn't trigger the InsertLeave autocmd . map to <ESC> instead.
"inoremap <c-c> <ESC>
" When the <Enter> key is pressed while the popup menu is visible, it only
" hides the menu. Use this mapping to close the menu and also start a new
" line.
"inoremap <expr> <CR> (pumvisible() ? "\<c-y>\<cr>" : "\<CR>")
" Use <TAB> to select the popup menu:
"inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
"inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" ==============================================================================
" Rust
" ==============================================================================
" Set updatetime for CursorHold
" 300ms of no cursor movement to trigger CursorHold
set updatetime=300
" have a fixed column for the diagnostics to appear in
" this removes the jitter when warnings/errors flow in
set signcolumn=yes
" Set completeopt to have a better completion experience
" :help completeopt
" menuone: popup even when there's only one match
" noinsert: Do not insert text until a selection is made
" noselect: Do not select, force user to select one from the menu
set completeopt=menuone,noinsert,noselect
" Avoid showing extra messages when using completion
set shortmess+=c
" Show diagnostic popup on cursor hold
autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
" format-on-write
autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 200)
" use 4 spaces for indent rust
autocmd FileType rust setlocal expandtab shiftwidth=4 softtabstop=4
let g:rustfmt_autosave = 1
let g:rustfmt_emit_files = 1
let g:rustfmt_fail_silently = 0
"let g:ale_linters = {'rust': ['analyzer']}
"au Filetype rust set colorcolumn=80
"au Filetype c set colorcolumn=80
"let g:LanguageClient_serverCommands = {
" \ 'rust': ['rust-analyzer'],
" \ }
"let g:ale_linters = {'rust': ['rustc', 'rls']}
luafile ~/.config/nvim/lua/simrat39__rust-tools.lua
luafile ~/.config/nvim/lua/hrsh7th__nvim-cmp.lua
" ==============================================================================
" Indentation
" ==============================================================================
" use 2 spaces for indentation of specific file types
autocmd FileType lua setlocal expandtab shiftwidth=2 softtabstop=2
autocmd FileType json setlocal expandtab shiftwidth=2 softtabstop=2
" use 4 spaces for indentation of specific file types
autocmd FileType bash setlocal expandtab shiftwidth=4 softtabstop=4
autocmd FileType c setlocal expandtab shiftwidth=4 softtabstop=4
autocmd FileType gitconfig setlocal expandtab shiftwidth=4 softtabstop=4
autocmd FileType python setlocal expandtab shiftwidth=4 softtabstop=4
autocmd FileType sh setlocal expandtab shiftwidth=4 softtabstop=4
autocmd FileType vim setlocal expandtab shiftwidth=4 softtabstop=4
autocmd FileType yaml setlocal expandtab shiftwidth=4 softtabstop=4
" ==============================================================================
@ -200,9 +231,25 @@ nnoremap <C-H> <C-W><C-H>
"enable nerdtree with ^\
map <C-Bslash> :NERDTreeToggle<CR>
" RUST
" Code navigation shortcuts
nnoremap <silent> <c-]> <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
nnoremap <silent> gD <cmd>lua vim.lsp.buf.implementation()<CR>
nnoremap <silent> <c-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
nnoremap <silent> 1gD <cmd>lua vim.lsp.buf.type_definition()<CR>
nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
nnoremap <silent> g0 <cmd>lua vim.lsp.buf.document_symbol()<CR>
nnoremap <silent> gW <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
" code actions
nnoremap <silent> ga <cmd>lua vim.lsp.buf.code_action()<CR>
" Goto previous/next diagnostic warning/error
nnoremap <silent> g[ <cmd>lua vim.diagnostic.goto_prev()<CR>
nnoremap <silent> g] <cmd>lua vim.diagnostic.goto_next()<CR>
" ==============================================================================
" change highlight color when yanking
" ==============================================================================
au TextYankPost * silent! lua vim.highlight.on_yank {higroup="Visual", timeout=250}

View File

@ -0,0 +1,32 @@
local cmp = require'cmp'
cmp.setup({
-- Enable LSP snippets
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
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 = 'vsnip' },
{ name = 'path' },
{ name = 'buffer' },
},
})

View File

@ -0,0 +1,170 @@
local opts = {
tools = { -- rust-tools options
-- how to execute terminal commands
-- options right now: termopen / quickfix
executor = require("rust-tools/executors").termopen,
-- callback to execute once rust-analyzer is done initializing the workspace
-- The callback receives one parameter indicating the `health` of the server: "ok" | "warning" | "error"
on_initialized = nil,
-- automatically call RustReloadWorkspace when writing to a Cargo.toml file.
reload_workspace_from_cargo_toml = true,
-- These apply to the default RustSetInlayHints command
inlay_hints = {
-- automatically set inlay hints (type hints)
-- default: true
auto = true,
-- Only show inlay hints for the current line
only_current_line = false,
-- whether to show parameter hints with the inlay hints or not
-- default: true
show_parameter_hints = true,
-- prefix for parameter hints
-- default: "<-"
parameter_hints_prefix = "<- ",
-- prefix for all the other hints (type, chaining)
-- default: "=>"
other_hints_prefix = "=> ",
-- whether to align to the length of the longest line in the file
max_len_align = false,
-- padding from the left if max_len_align is true
max_len_align_padding = 1,
-- whether to align to the extreme right or not
right_align = false,
-- padding from the right if right_align is true
right_align_padding = 7,
-- The color of the hints
highlight = "Comment",
},
-- options same as lsp hover / vim.lsp.util.open_floating_preview()
hover_actions = {
-- the border that is used for the hover window
-- see vim.api.nvim_open_win()
border = {
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
},
-- whether the hover action window gets automatically focused
-- default: false
auto_focus = false,
},
-- settings for showing the crate graph based on graphviz and the dot
-- command
crate_graph = {
-- Backend used for displaying the graph
-- see: https://graphviz.org/docs/outputs/
-- default: x11
backend = "x11",
-- where to store the output, nil for no output stored (relative
-- path from pwd)
-- default: nil
output = nil,
-- true for all crates.io and external crates, false only the local
-- crates
-- default: true
full = true,
-- List of backends found on: https://graphviz.org/docs/outputs/
-- Is used for input validation and autocompletion
-- Last updated: 2021-08-26
enabled_graphviz_backends = {
"bmp",
"cgimage",
"canon",
"dot",
"gv",
"xdot",
"xdot1.2",
"xdot1.4",
"eps",
"exr",
"fig",
"gd",
"gd2",
"gif",
"gtk",
"ico",
"cmap",
"ismap",
"imap",
"cmapx",
"imap_np",
"cmapx_np",
"jpg",
"jpeg",
"jpe",
"jp2",
"json",
"json0",
"dot_json",
"xdot_json",
"pdf",
"pic",
"pct",
"pict",
"plain",
"plain-ext",
"png",
"pov",
"ps",
"ps2",
"psd",
"sgi",
"svg",
"svgz",
"tga",
"tiff",
"tif",
"tk",
"vml",
"vmlz",
"wbmp",
"webp",
"xlib",
"x11",
},
},
},
-- all the opts to send to nvim-lspconfig
-- these override the defaults set by rust-tools.nvim
-- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer
server = {
-- standalone file support
-- setting it to false may improve startup time
standalone = true,
}, -- rust-analyzer options
-- debugging stuff
dap = {
adapter = {
type = "executable",
command = "lldb-vscode",
name = "rt_lldb",
},
},
}
require('rust-tools').setup(opts)

View File

@ -123,6 +123,7 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
alias confont="setfont /usr/share/consolefonts/Lat2-Terminus28x14.psf.gz"
alias drivetemp="sudo hdparm -CH /dev/sda /dev/sdb /dev/sdc /dev/sdd"
alias containerupdate='podman auto-update --dry-run --format="{{.Unit}}\t{{.Updated}}"'
alias containerfreeall="podman system prune -a"
alias containerdisableall="systemctl --user disable container-gitea-chitragupta container-hugo-vaikunthnatham container-nextcloud-chitragupta container-hugo-mahayogi container-gitea-govinda container-nextcloud-govinda container-transmission-raadhe container-caddy-vishwambhar"
alias containerenableall="systemctl --user enable container-gitea-chitragupta container-hugo-vaikunthnatham container-nextcloud-chitragupta container-hugo-mahayogi container-gitea-govinda container-nextcloud-govinda container-transmission-raadhe container-caddy-vishwambhar"