Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init.vim #1

Open
wangw469 opened this issue Nov 27, 2023 · 1 comment
Open

init.vim #1

wangw469 opened this issue Nov 27, 2023 · 1 comment

Comments

@wangw469
Copy link
Owner

local vimrc = vim.fn.stdpath("config") .. "/vimrc.vim"
vim.cmd.source(vimrc)

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup(
({
{'nvim-telescope/telescope.nvim', dependencies = { 'nvim-lua/plenary.nvim' }},
'mfussenegger/nvim-jdtls',
'williamboman/mason.nvim',
"williamboman/mason-lspconfig.nvim",
"neovim/nvim-lspconfig",
'nvim-treesitter/nvim-treesitter',
})
)

require("mason").setup()
require("mason-lspconfig").setup()

require'lspconfig'.pyright.setup{}
require'lspconfig'.tsserver.setup{}

vim.keymap.set('n', '', require'telescope.builtin'.live_grep)

-- Global mappings.
-- See :help vim.diagnostic.* for documentation on any of the below functions
vim.keymap.set('n', 'e', vim.diagnostic.open_float)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
vim.keymap.set('n', 'q', vim.diagnostic.setloclist)

-- Use LspAttach autocommand to only map the following keys
-- after the language server attaches to the current buffer
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
-- Enable completion triggered by
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'

-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set('n', '<space>wl', function()
  print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<space>f', function()
  vim.lsp.buf.format { async = true }
end, opts)

end,
})

@wangw469
Copy link
Owner Author

" view
set wildmenu
syntax on

if has("gui_vimr") || has("gui_running")
" Here goes some VimR specific settings like
set guifont=courier\ new:h20
color delek
set background=light
else
set guifont=courier\ new:h20
color default
set background=dark
endif

set complete-=i

" file format
" " tabstop: Width of tab character
" softtabstop: Fine tunes the amount of white space to be added
" shiftwidth Determines the amount of whitespace to add in normal mode
" expandtab: When this option is enabled, vi will use spaces instead of tabs
set tabstop =4
set softtabstop =4
set shiftwidth =4
set expandtab

set autoindent
set nonumber
filetype plugin indent on
" set colorcolumn=80
" set textwidth=80
" set formatoptions+=m

" Note, perl automatically sets foldmethod in the syntax file
"autocmd Syntax c,cpp,vim,xml,html,xhtml,lua setlocal foldmethod=syntax
"autocmd Syntax c,cpp,vim,xml,html,xhtml,perl,lua normal zR

" set laststatus=2
" if has("statusline")
" set statusline=%<%f\ %h%m%r%=%{"[".(&fenc==""?&enc:&fenc).((exists("+bomb")\ &&\ &bomb)?",B":"")."]\ "}%k\ %-14.(%l,%c%V%)\ %P
" endif

" search & file navagation shortcuts
set hlsearch
set incsearch

nnoremap :Ag -s -f -w
nnoremap :copen :cnext
nnoremap :copen :cpre
nnoremap :cclose
nnoremap :NERDTreeFind
nnoremap :tabp
nnoremap :tabn
nnoremap :tabnew
nnoremap :tabc
nnoremap
nnoremap
nnoremap :noh

" toolkit
" nmap cp :let @* = expand("%:p")

function! g:ChmodOnWrite()
if v:cmdbang
silent !chmod u+w %
endif
endfunction

autocmd! bufwritepost vimrc source %

" auto save for every second
" set autosave=1

" if has("multi_byte")
" if &termencoding == ""
" let &termencoding = &encoding
" endif
" set encoding=utf-8
" setglobal fileencoding=utf-8
" "setglobal bomb
" set fileencodings=ucs-bom,utf-8,latin1
" endif

" find files and populate the quickfix list
" fun! FindFiles(filename)
" let error_file = tempname()
" silent exe '!find . -name "'.a:filename.'" | xargs file | sed "s/:/:1:/" > '.error_file
" set errorformat=%f:%l:%m
" exe "cfile ". error_file
" copen
" call delete(error_file)
" endfun
" command! -nargs=1 FindFile call FindFiles()
imap jj

execute pathogen#infect()

" ------------------------------------
" plugins
" ------------------------------------
" .vimrc
let g:auto_save = 1 " enable AutoSave on Vim startup
" ctrlp
" cd ~/.vim/bundle &&
" git clone https://github.com/kien/ctrlp.vim.git
" let g:ctrlp_map = ''
" let g:ctrlp_cmd = 'CtrlP'
" let g:ctrlp_working_path_mode = 'ra'
"
"" set wildignore+=/tmp/,.so,.swp,.zip " MacOSX/Linux
"let g:airline#extensions#tabline#enabled = 1
"
" let g:ctrlp_user_command = 'find %s -type f'
" let g:ctrlp_map = ''
" let g:ctrlp_working_path_mode = ''
" set wildignore+=
/tmp/,.so,.swp,.zip,/.svn/,.bak,/aos_v1/,/v3quick/,/v3quick_aos/
" let g:ctrlp_custom_ignore = {
" \ 'dir': '\v[/].(git|hg|svn)$',
" \ 'file': '\v.(exe|so|dll|bak|swp)$',
" \ 'link': 'some_bad_symbolic_links',
" \ }
" let g:ctrlp_regexp = 1

" cd ~/.vim/bundle
" git clone https://github.com/Lokaltog/vim-easymotion
let g:EasyMotion_do_mapping = 0 " Disable default mappings

" Bi-directional find motion
" Jump to anywhere you want with minimal keystrokes, with just one key binding.
" s{char}{label}
nmap s (easymotion-s)
" or
" s{char}{char}{label}
" Need one more keystroke, but on average, it may be more comfortable.
nmap s (easymotion-s2)

" Turn on case sensitive feature
let g:EasyMotion_smartcase = 1

" JK motions: Line motions
map j (easymotion-j)
map k (easymotion-k)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant