Better comments, nerdtree settings
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
" Basic editor behavior
|
||||||
set relativenumber
|
set relativenumber
|
||||||
set number
|
set number
|
||||||
set autoindent
|
set autoindent
|
||||||
@@ -5,29 +6,30 @@ set clipboard+=unnamed " Use system clipboard
|
|||||||
set termguicolors
|
set termguicolors
|
||||||
set cursorline
|
set cursorline
|
||||||
set ts=4 sw=4
|
set ts=4 sw=4
|
||||||
"gets rid of --INSERT-- useful bc of lighline"
|
" Lightline already shows the current mode, so hide the default mode text.
|
||||||
set noshowmode
|
set noshowmode
|
||||||
set mouse=a
|
set mouse=a
|
||||||
"splits"
|
" Open new splits in the more common IDE-like directions.
|
||||||
set splitright
|
set splitright
|
||||||
set splitbelow
|
set splitbelow
|
||||||
|
|
||||||
|
" Plugins
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
"file explorer"
|
" File explorer
|
||||||
Plug 'preservim/nerdtree'
|
Plug 'preservim/nerdtree'
|
||||||
"status line"
|
" Status line
|
||||||
Plug 'itchyny/lightline.vim'
|
Plug 'itchyny/lightline.vim'
|
||||||
"color themes"
|
" Colorschemes
|
||||||
Plug 'gilgigilgil/anderson.vim'
|
Plug 'gilgigilgil/anderson.vim'
|
||||||
Plug 'sainnhe/sonokai'
|
Plug 'sainnhe/sonokai'
|
||||||
"automatic parentheses"
|
" Automatic bracket and quote pairing
|
||||||
Plug 'jiangmiao/auto-pairs'
|
Plug 'jiangmiao/auto-pairs'
|
||||||
"syntax highlighting"
|
" Syntax highlighting and structural selection
|
||||||
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
||||||
"shortcut to comment multiple lines"
|
" Commenting helpers
|
||||||
Plug 'numToStr/Comment.nvim'
|
Plug 'numToStr/Comment.nvim'
|
||||||
|
|
||||||
|
" Completion and snippet support
|
||||||
Plug 'neovim/nvim-lspconfig'
|
Plug 'neovim/nvim-lspconfig'
|
||||||
Plug 'hrsh7th/cmp-nvim-lsp'
|
Plug 'hrsh7th/cmp-nvim-lsp'
|
||||||
Plug 'hrsh7th/cmp-buffer'
|
Plug 'hrsh7th/cmp-buffer'
|
||||||
@@ -35,7 +37,7 @@ Plug 'hrsh7th/cmp-path'
|
|||||||
Plug 'hrsh7th/cmp-cmdline'
|
Plug 'hrsh7th/cmp-cmdline'
|
||||||
Plug 'hrsh7th/nvim-cmp'
|
Plug 'hrsh7th/nvim-cmp'
|
||||||
|
|
||||||
" For vsnip users.
|
" Snippet backend used by nvim-cmp
|
||||||
Plug 'hrsh7th/cmp-vsnip'
|
Plug 'hrsh7th/cmp-vsnip'
|
||||||
Plug 'hrsh7th/vim-vsnip'
|
Plug 'hrsh7th/vim-vsnip'
|
||||||
|
|
||||||
@@ -43,15 +45,56 @@ call plug#end()
|
|||||||
|
|
||||||
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
|
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
|
||||||
|
|
||||||
" Start NERDTree fullscreen if no file specified, otherwise open in split
|
" NERDTree startup behavior
|
||||||
|
" - No file argument: open the tree fullscreen.
|
||||||
|
" - File argument or stdin: open the tree on the side and return focus to the file.
|
||||||
|
" - If the tree is the last remaining window, quit Neovim.
|
||||||
autocmd StdinReadPre * let s:std_in=1
|
autocmd StdinReadPre * let s:std_in=1
|
||||||
|
autocmd VimEnter * call s:RegisterNERDTreeVSplitOverride()
|
||||||
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | execute 'NERDTree' | only | endif
|
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | execute 'NERDTree' | only | endif
|
||||||
autocmd VimEnter * if argc() > 0 || exists("s:std_in") | NERDTree | wincmd p | endif
|
autocmd VimEnter * if argc() > 0 || exists("s:std_in") | NERDTree | wincmd p | endif
|
||||||
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
|
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
|
||||||
|
|
||||||
|
" Close NERDTree after opening a file from it.
|
||||||
|
let g:NERDTreeQuitOnOpen = 1
|
||||||
|
|
||||||
|
" Open a file from NERDTree in a vertical split and close the tree.
|
||||||
|
function! NERDTreeOpenVSplitAndClose(node) abort
|
||||||
|
call a:node.activate({'where': 'v', 'keepopen': 0})
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Same behavior as above, but for bookmarked nodes.
|
||||||
|
function! NERDTreeOpenVSplitBookmarkAndClose(bookmark) abort
|
||||||
|
call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'where': 'v', 'keepopen': 0} : {})
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Override NERDTree's default `s` action once the plugin has been loaded.
|
||||||
|
function! s:RegisterNERDTreeVSplitOverride() abort
|
||||||
|
if !exists('*NERDTreeAddKeyMap')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
call NERDTreeAddKeyMap({
|
||||||
|
\ 'key': 's',
|
||||||
|
\ 'scope': 'FileNode',
|
||||||
|
\ 'callback': 'NERDTreeOpenVSplitAndClose',
|
||||||
|
\ 'quickhelpText': 'open vsplit and close tree',
|
||||||
|
\ 'override': 1
|
||||||
|
\ })
|
||||||
|
call NERDTreeAddKeyMap({
|
||||||
|
\ 'key': 's',
|
||||||
|
\ 'scope': 'Bookmark',
|
||||||
|
\ 'callback': 'NERDTreeOpenVSplitBookmarkAndClose',
|
||||||
|
\ 'quickhelpText': 'open vsplit and close tree',
|
||||||
|
\ 'override': 1
|
||||||
|
\ })
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Core NERDTree shortcuts
|
||||||
nnoremap <leader>n :NERDTreeFocus<CR>
|
nnoremap <leader>n :NERDTreeFocus<CR>
|
||||||
nnoremap <C-t> :NERDTreeToggle<CR>
|
nnoremap <C-t> :NERDTreeToggle<CR>
|
||||||
let g:NERDTreeGitStatusWithFlags = 1
|
let g:NERDTreeGitStatusWithFlags = 1
|
||||||
|
" Example icon and color overrides kept here for later use.
|
||||||
"let g:WebDevIconsUnicodeDecorateFolderNodes = 1
|
"let g:WebDevIconsUnicodeDecorateFolderNodes = 1
|
||||||
"let g:NERDTreeGitStatusNodeColorization = 1
|
"let g:NERDTreeGitStatusNodeColorization = 1
|
||||||
"let g:NERDTreeColorMapCustom = {
|
"let g:NERDTreeColorMapCustom = {
|
||||||
@@ -67,34 +110,44 @@ let g:NERDTreeGitStatusWithFlags = 1
|
|||||||
|
|
||||||
let g:NERDTreeIgnore = ['^node_modules$']
|
let g:NERDTreeIgnore = ['^node_modules$']
|
||||||
|
|
||||||
|
" Lightline appearance
|
||||||
let g:lightline = {
|
let g:lightline = {
|
||||||
\ 'colorscheme': 'wombat',
|
\ 'colorscheme': 'wombat',
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
|
" Colorscheme configuration
|
||||||
let g:sonokai_style = 'shusia'
|
let g:sonokai_style = 'shusia'
|
||||||
let g:sonokai_better_performance = 1
|
let g:sonokai_better_performance = 1
|
||||||
colorscheme sonokai
|
colorscheme sonokai
|
||||||
|
|
||||||
lua << EOF
|
lua << EOF
|
||||||
require'nvim-treesitter.configs'.setup {
|
-- Treesitter config: prefer the older `configs` entrypoint, but fall back to
|
||||||
-- Install parsers for languages you use
|
-- the newer top-level module for the version currently installed locally.
|
||||||
ensure_installed = { "c", "cpp", "python", "lua", "vim", "go", "html", "css", "javascript", "ocaml"},
|
local ok, ts = pcall(require, 'nvim-treesitter.configs')
|
||||||
|
if not ok then
|
||||||
|
ok, ts = pcall(require, 'nvim-treesitter')
|
||||||
|
end
|
||||||
|
|
||||||
-- Install all maintained parsers
|
if ok then
|
||||||
|
ts.setup {
|
||||||
|
-- Parsers to install automatically.
|
||||||
|
ensure_installed = { "c", "cpp", "python", "lua", "vim", "go", "html", "css", "javascript", "ocaml" },
|
||||||
|
|
||||||
|
-- Install all maintained parsers instead.
|
||||||
-- ensure_installed = "all",
|
-- ensure_installed = "all",
|
||||||
|
|
||||||
-- Syntax highlighting
|
-- Treesitter-powered syntax highlighting.
|
||||||
highlight = {
|
highlight = {
|
||||||
enable = true,
|
enable = true,
|
||||||
additional_vim_regex_highlighting = false,
|
additional_vim_regex_highlighting = false,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Indentation based on treesitter (experimental)
|
-- Treesitter indentation where supported.
|
||||||
indent = {
|
indent = {
|
||||||
enable = true
|
enable = true
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Incremental selection based on the syntax tree
|
-- Grow and shrink selections by syntax node instead of by raw text.
|
||||||
incremental_selection = {
|
incremental_selection = {
|
||||||
enable = true,
|
enable = true,
|
||||||
keymaps = {
|
keymaps = {
|
||||||
@@ -104,19 +157,24 @@ require'nvim-treesitter.configs'.setup {
|
|||||||
node_decremental = "grm",
|
node_decremental = "grm",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
-- Keep startup working even if Treesitter is installed incorrectly.
|
||||||
|
vim.notify('nvim-treesitter is installed but could not be loaded', vim.log.levels.WARN)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Enable default comment mappings like gcc and gc.
|
||||||
require('Comment').setup()
|
require('Comment').setup()
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
lua <<EOF
|
lua <<EOF
|
||||||
-- Set up nvim-cmp.
|
-- Completion setup
|
||||||
local cmp = require'cmp'
|
local cmp = require'cmp'
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
snippet = {
|
snippet = {
|
||||||
-- REQUIRED - you must specify a snippet engine
|
-- nvim-cmp needs a snippet expansion function, and this config uses vsnip.
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||||
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||||
@@ -140,7 +198,14 @@ lua <<EOF
|
|||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
['<C-Space>'] = cmp.mapping.complete(),
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
['<C-e>'] = cmp.mapping.abort(),
|
['<C-e>'] = cmp.mapping.abort(),
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
-- Use Tab to confirm the current completion item, otherwise keep normal Tab behavior.
|
||||||
|
['<Tab>'] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.confirm({ select = true })
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' }),
|
||||||
}),
|
}),
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
@@ -153,8 +218,7 @@ lua <<EOF
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
-- To use git you need to install the plugin petertriho/cmp-git and uncomment lines below
|
-- Example git completion setup left commented out for future use.
|
||||||
-- Set configuration for specific filetype.
|
|
||||||
--[[ cmp.setup.filetype('gitcommit', {
|
--[[ cmp.setup.filetype('gitcommit', {
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'git' },
|
{ name = 'git' },
|
||||||
@@ -164,7 +228,7 @@ lua <<EOF
|
|||||||
})
|
})
|
||||||
require("cmp_git").setup() ]]--
|
require("cmp_git").setup() ]]--
|
||||||
|
|
||||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
-- Use buffer completion while searching with `/` or `?`.
|
||||||
cmp.setup.cmdline({ '/', '?' }, {
|
cmp.setup.cmdline({ '/', '?' }, {
|
||||||
mapping = cmp.mapping.preset.cmdline(),
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
sources = {
|
sources = {
|
||||||
@@ -172,7 +236,7 @@ lua <<EOF
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
-- Use path and command completion for `:`.
|
||||||
cmp.setup.cmdline(':', {
|
cmp.setup.cmdline(':', {
|
||||||
mapping = cmp.mapping.preset.cmdline(),
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
@@ -183,7 +247,7 @@ lua <<EOF
|
|||||||
matching = { disallow_symbol_nonprefix_matching = false }
|
matching = { disallow_symbol_nonprefix_matching = false }
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Set up lspconfig.
|
-- Placeholder LSP wiring kept here because cmp-nvim-lsp is installed.
|
||||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
|
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
|
||||||
vim.lsp.config('<YOUR_LSP_SERVER>', {
|
vim.lsp.config('<YOUR_LSP_SERVER>', {
|
||||||
|
|||||||
Reference in New Issue
Block a user