" Set GUI font
set guifont=FiraCode\ Nerd\ Font:h16
syntax on
set number
set relativenumber
set mouse=a
set tabstop=4
set shiftwidth=4
set expandtab
set autoindent
set smartindent
set cursorline
filetype plugin indent on
set clipboard=unnamed
set hidden
set incsearch
set ignorecase
set smartcase
set undofile
set undodir=~/.vim/undodir
if !isdirectory(&undodir)
call mkdir(&undodir, "p", 0700)
endif
" Initialize plugin manager
call plug#begin('~/.vim/plugged')
" Plugins
Plug 'Vimjas/vim-python-pep8-indent' " Better Python indentation
Plug 'heavenshell/vim-pydocstring' " Python docstring generation
Plug 'jeetsukumaran/vim-pythonsense' " Better Python text objects and motions
Plug 'vim-python/python-syntax' " Enhanced Python syntax
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'preservim/nerdtree'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'sheerun/vim-polyglot'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'jiangmiao/auto-pairs'
Plug 'tpope/vim-commentary'
Plug 'honza/vim-snippets'
Plug 'preservim/nerdtree'
Plug 'preservim/nerdcommenter'
Plug 'ycm-core/YouCompleteMe'
Plug 'morhetz/gruvbox'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'airblade/vim-gitgutter'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'scrooloose/nerdtree'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'ryanoasis/vim-devicons'
Plug 'dense-analysis/ale'
Plug 'psf/black', { 'do': ':BlackUpgrade' }
Plug 'jiangmiao/auto-pairs'
Plug 'tpope/vim-commentary'
Plug 'mfussenegger/nvim-dap-python'
Plug 'rcarriga/nvim-dap-ui'
Plug 'theHamsta/nvim-dap-virtual-text'
Plug 'mhinz/vim-startify'
Plug 'arcticicestudio/nord-vim'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'folke/tokyonight.nvim'
Plug 'sheerun/vim-polyglot'
Plug 'luochen1990/rainbow'
Plug 'nvie/vim-flake8'
Plug 'crusoexia/vim-monokai'
Plug 'ghifarit53/tokyonight-vim'
Plug 'tpope/vim-commentary'
Plug 'lukas-reineke/indent-blankline.nvim'
Plug 'puremourning/vimspector'
Plug 'fisadev/vim-isort'
Plug 'asvetliakov/vim-easymotion' " VSCode-like navigation
Plug 'machakann/vim-highlightedyank' " Highlight yanked text
Plug 'artur-shaik/vim-javacomplete2'
Plug 'tpope/vim-fugitive'
" SQL/Database plugins
Plug 'tpope/vim-dadbod'
Plug 'kristijanhusak/vim-dadbod-ui'
Plug 'kristijanhusak/vim-dadbod-completion'
Plug 'shmup/vim-sql-syntax'
call plug#end()
" CSV/Excel viewer settings
let g:csv_delim=','
let g:csv_highlight_column = 'y'
let g:csv_nomap_cr = 1
" General settings
" Ensure Python support is enabled
if has('python3')
let g:python3_host_prog = '/opt/miniconda3/bin/python3.12'
endif
inoremap <silent><expr> <Enter> pumvisible() ? coc#_select_confirm() : "\<CR>"
let g:no_flake8_maps = 1
syntax on
filetype plugin indent on
let g:flake8_auto_check = 1 " Enable automatic checking
set expandtab
set tabstop=4
set shiftwidth=4
set autoindent
set smartindent
set nowrap
set background=dark
set clipboard=unnamedplus
set completeopt=menuone,noinsert,noselect
" Colorscheme
set termguicolors
let g:airline_theme='tokyonight'
let g:tokyonight_style = 'night'
let g:tokyonight_enable_italic = 1
colorscheme tokyonight
" NERDTree setting
nnoremap <C-b> :NERDTreeToggle<CR> " Instead of Ctrl+N
nnoremap <C-,> :e $MYVIMRC<CR> " Open settings
nnoremap <C-t> :terminal<CR> " Toggle terminal
" Ignore specific files and directories in NERDTree
let NERDTreeIgnore=['\.pyc$', '\~$', '^\.git$']
" Do not show the root directory
let NERDTreeShowBookmarks=1
let NERDTreeChDirMode=2
" Open NERDTree on startup if no files are opened
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | wincmd p | endif
" Change the working directory to the file in the buxer
autocmd BufEnter * if &buftype == '' | lcd %:p:h | endif
autocmd StdinReadPre * let s:std_in=1
nnoremap <C-p> :Files<CR>
nnoremap <C-s> :w<CR>
nnoremap <C-w> :bd<CR>
nnoremap <C-f> :Rg<CR>
" Python development settings
let g:ycm_python_binary_path = '/opt/miniconda3/bin/python3.12'
let g:coc_global_extensions = ['coc-pyright']
autocmd FileType python nnoremap <leader>f :Black<CR>
let g:ale_fix_on_save = 1
let g:ale_linters = {'python': ['flake8', 'pylint']}
let g:ale_python_flake8_executable = 'flake8'
let g:ale_python_flake8_options = '--max-line-length=120 --select=E,F --
ignore=E501,E203,E231,E251,W291,W391'
let g:ale_python_pylint_options = '--errors-only'
let g:ale_completion_enabled = 1
let g:ale_warn_about_trailing_whitespace = 0
let g:ale_fixers = {'python': ['isort']}
let g:ale_fix_on_save = 1
" Airline configuration
let g:airline#extensions#ale#enabled = 1
let g:airline_powerline_fonts = 1
" Rainbow parentheses
let g:rainbow_active = 1
" Debugging keybindings "
" Map keys for Vimspector debugging
nmap <F5> :call vimspector#Launch()<CR>
nmap <F8> :call vimspector#StepOver()<CR>
nmap <F9> :call vimspector#StepInto()<CR>
nmap <F10> :call vimspector#StepOut()<CR>
nmap <F12> :call vimspector#Reset()<CR>
nmap <leader>b :call vimspector#ToggleBreakpoint()<CR>
nmap <leader>B :call vimspector#ClearBreakpoints()<CR>
" ALE settings "
"
let g:ale_linters = {
\ 'python': ['pylint', 'flake8'],
\}
" Configure Pylint to show only errors
let g:ale_python_pylint_options = '--errors-only --disable=C,R,W'
" Configure Flake8 to show only serious errors
let g:ale_python_flake8_options = '--select=E9,F63,F7,F82 --ignore=E,W,F405,F403'
" Disable ALE fixing on save since we only want error checking
let g:ale_fix_on_save = 0
" Don't show warnings
let g:ale_type_map = {
\ 'warning': 'error',
\}
" Only show errors in the quickfix list
let g:ale_set_quickfix = 1
let g:ale_set_loclist = 0
let g:ale_open_list = 1
let g:ale_list_vertical = 0
let g:ale_set_signs = 1
let g:ale_sign_error = ' '
let g:ale_sign_warning = ' '
"Flake8 configuration for serious errors only
"
let g:flake8_show_in_gutter = 1
let g:flake8_error_marker = ''
let g:flake8_quickfix_location = "botright"
let g:flake8_quickfix_height = 7
let g:flake8_show_quickfix = 1
" Only show serious errors
let g:flake8_options = '--select=E9,F63,F7,F82 --ignore=E,W,F405,F403'
let g:flake8_error_marker = ' '
let g:flake8_warning_marker = ' '
highlight link Flake8_Error Error
highlight link Flake8_Warning WarningMsg
" Keybinding for showing flake8 errors "
nnoremap <C-K> :call flake8#Flake8ShowError()<CR>
" Auto-run flake8 on save for Python files "
autocmd BufWritePost *.py call flake8#Flake8()
autocmd BufWritePre *.py silent! execute ':!isort %'
" Commenting "
autocmd FileType python vnoremap <Leader>c :s/^/#/<CR>:noh<CR>
autocmd FileType python vnoremap <Leader>u :s/^#//<CR>:noh<CR>
nnoremap <C-r> :w<CR>:! /opt/anaconda3/bin/python3.12 %<CR>
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Custom command to format Python imports with parentheses if >= 5 imports
command! FormatPythonImports %!isort --force-wrap --lines-after-imports 2 -
" Map <Leader>i to format Python imports
autocmd FileType python nnoremap <Leader>0 :FormatPythonImports<CR>
" Function to format Python imports with parentheses if >= 5 imports
function! FormatPythonImports()
" Save the cursor position
let l:save_cursor = getpos('.')
" Search for Python import statements
silent! execute 'g/^from\s\+\S\+\s\+import\s\+/normal! f(lvt)'
" Check if the line has >= 5 imports
if len(split(getline('.'), ',')) >= 5
" Add parentheses and newlines
silent! execute 's/import \zs\(.\+\)/\(\r \1\r\)/'
silent! execute 's/, /,\r /g'
endif
" Restore the cursor position
call setpos('.', l:save_cursor)
endfunction
" Map the function to a command
command! FormatPythonImports call FormatPythonImports()
" Optional: Map a keybinding to the command (e.g., <Leader>i)
autocmd FileType python nnoremap <Leader>0 :FormatPythonImports<CR>
autocmd FileType python autocmd BufWritePre <buxer> execute ':silent !isort %'
" SQL/Database configurations
let g:db_ui_save_location = '~/.vim/db_ui'
let g:db_ui_use_nerd_fonts = 1
let g:db_ui_execute_on_save = 0
" SQL formatting
let g:sqlfmt_command = "sqlformat"
let g:sqlfmt_options = "-r -k upper"
" SQL completion
autocmd FileType sql setlocal omnifunc=vim_dadbod_completion#omni
autocmd FileType sql,mysql,plsql setlocal keywordprg=:DBUIFindBuxer
" Key mappings for database operations
nnoremap <silent> <leader>db :DBUIToggle<CR>
nnoremap <silent> <leader>df :DBUIFindBuxer<CR>
nnoremap <silent> <leader>dr :DBUIRenameBuxer<CR>
nnoremap <silent> <leader>dl :DBUILastQueryInfo<CR>
" PYTHON SETUP
" Python-specific mappings
autocmd FileType python map <leader>b Oimport pdb; pdb.set_trace()<esc> " Add
breakpoint
autocmd FileType python map <leader>B Oimport ipdb; ipdb.set_trace()<esc> " Add
IPython breakpoint
autocmd FileType python nnoremap <leader>d :g/^\s*import pdb/d<CR> " Remove all
breakpoints
" Quick function/class navigation
autocmd FileType python nnoremap <leader>f /def <CR>
autocmd FileType python nnoremap <leader>c /class <CR>
" Quick test running
autocmd FileType python nnoremap <leader>t :!python -m pytest %<CR>
autocmd FileType python nnoremap <leader>T :!python -m pytest<CR>
" Enhanced Python syntax
let g:python_highlight_all = 1
let g:python_highlight_func_calls = 1
let g:python_highlight_builtins = 1
let g:python_highlight_exceptions = 1
let g:python_highlight_string_formatting = 1
" Pydocstring settings
let g:pydocstring_formatter = 'google'
nmap <silent> <leader>ds <Plug>(pydocstring)
" Enhanc folding
let g:SimpylFold_docstring_preview = 1
let g:SimpylFold_fold_docstring = 0
let g:SimpylFold_fold_import = 0
set foldmethod=indent
set foldlevel=99
" Python completion settings
autocmd FileType python set completeopt-=preview " Disable scratch preview
autocmd FileType python set complete+=t
autocmd FileType python set formatoptions-=t
autocmd FileType python set nowrap
autocmd FileType python set sidescroll=5
autocmd FileType python set listchars+=precedes:<,extends:>
" Python completion settings
autocmd FileType python set completeopt-=preview " Disable scratch preview
autocmd FileType python set complete+=t
autocmd FileType python set formatoptions-=t
autocmd FileType python set nowrap
autocmd FileType python set sidescroll=5
autocmd FileType python set listchars+=precedes:<,extends:>
" Python template for new files
autocmd BufNewFile *.py 0r ~/.vim/templates/python.tpl
" Better Python error format
set errorformat=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
" Python status line
" ______________
function! PythonStatus()
let python_version = trim(system('python3 --version 2>&1 | cut -d" " -f2'))
let venv = $VIRTUAL_ENV != "" ? fnamemodify($VIRTUAL_ENV, ':t') : "system"
return printf('[Py:%s|%s]', python_version, venv)
endfunction
if exists('g:airline_section_x')
let g:airline_section_x = airline#section#create_right(['filetype', 'PythonStatus'])
endif
" Pyright configuration
let g:coc_user_config = {
\ 'python.analysis.typeCheckingMode': 'basic',
\ 'python.analysis.diagnosticMode': 'workspace',
\ 'python.analysis.autoSearchPaths': v:true,
\ 'python.analysis.useLibraryCodeForTypes': v:true,
\ 'python.analysis.diagnosticSeverityOverrides': {
\ 'reportGeneralTypeIssues': 'warning',
\ 'reportOptionalMemberAccess': 'warning',
\ 'reportOptionalSubscript': 'warning',
\ 'reportPrivateImportUsage': 'none',
\ 'reportUnboundVariable': 'error',
\ 'reportUndefinedVariable': 'error',
\ 'reportMissingImports': 'error',
\ 'reportMissingTypeStubs': 'none',
\ 'reportUnknownVariableType': 'none',
\ 'reportUnknownMemberType': 'none',
\ 'reportUnknownParameterType': 'none',
\ 'reportUnknownArgumentType': 'none',
\ 'reportInvalidTypeVarUse': 'warning',
\ 'reportAssertAlwaysTrue': 'none',
\ 'reportSelfClsParameterName': 'none'
\ }
\}
" Create pyrightconfig.json if it doesn't exist
if !filereadable('pyrightconfig.json')
call system('echo ''{"exclude": ["**/node_modules", "**/__pycache__"], "ignore": [],
"reportMissingImports": true, "reportMissingTypeStubs": false, "pythonVersion": "3.12"}''
> pyrightconfig.json')
endif