finalize neovim tranition from vimscript to lua (as much as I can)
This commit is contained in:
parent
318aafbdf2
commit
b178cc0d5c
|
@ -0,0 +1,15 @@
|
|||
--------------------------------------------------------------------------------
|
||||
-- Initial setup
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- disable netrw at the very start of init.lua (strongly advised by _nvim-tree.lua_)
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
|
||||
|
||||
require("plug-init")
|
||||
vim.cmd("source ~/.config/nvim/vim/cmd_opts.vim")
|
||||
require("autocmds")
|
||||
require("key-bindings")
|
||||
vim.cmd("source ~/.config/nvim/vim/statusline.vim")
|
||||
require("plug-setup")
|
|
@ -1,266 +0,0 @@
|
|||
" ==============================================================================
|
||||
" Plugins
|
||||
" ==============================================================================
|
||||
call plug#begin('~/.vim/plugged')
|
||||
|
||||
" base16 theme
|
||||
Plug 'chriskempson/base16-vim'
|
||||
|
||||
" treesitter
|
||||
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
||||
|
||||
" 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 'nvim-lua/plenary.nvim'
|
||||
Plug 'nvim-telescope/telescope.nvim'
|
||||
|
||||
" optional
|
||||
Plug 'airblade/vim-rooter'
|
||||
Plug 'nvim-lua/popup.nvim'
|
||||
Plug 'nvim-lua/plenary.nvim'
|
||||
Plug 'nvim-telescope/telescope.nvim'
|
||||
|
||||
" vim ripgrep
|
||||
Plug 'jremmen/vim-ripgrep'
|
||||
|
||||
" official rust plugin
|
||||
Plug 'rust-lang/rust.vim'
|
||||
" to enable more of the features of rust-analyzer, such as inlay hints and more!
|
||||
Plug 'simrat39/rust-tools.nvim'
|
||||
|
||||
" git wrapper
|
||||
Plug 'tpope/vim-fugitive'
|
||||
|
||||
" src tree view
|
||||
Plug 'nvim-tree/nvim-tree.lua'
|
||||
Plug 'nvim-tree/nvim-web-devicons' " optional, for file icons
|
||||
|
||||
call plug#end()
|
||||
" lua require("setup"
|
||||
luafile ~/.config/nvim/lua/setup.lua
|
||||
|
||||
|
||||
" ==============================================================================
|
||||
" Neovim core(?)
|
||||
" ==============================================================================
|
||||
" dealing with files
|
||||
syntax on
|
||||
filetype plugin indent on
|
||||
set paste
|
||||
set colorcolumn=80
|
||||
set autoindent expandtab tabstop=4 shiftwidth=4
|
||||
set encoding=utf-8
|
||||
|
||||
" appearance
|
||||
set number relativenumber
|
||||
set noshowmode
|
||||
set showcmd
|
||||
set timeoutlen=300 " (http://stackoverflow.com/questions/2158516/delay-before-o-opens-a-new-line)
|
||||
set spell
|
||||
set termguicolors
|
||||
set cursorline
|
||||
let base16colorspace=256
|
||||
colorscheme base16-google-dark
|
||||
"colorscheme base16-gruvbox-dark-hard
|
||||
"set cursorcolumn
|
||||
|
||||
"set clipboard=unnamed,unnamedplus
|
||||
set title
|
||||
set noswapfile
|
||||
"set lazyredraw
|
||||
"set ttyfast (https://neovim.io/doc/user/vim_diff.html#'ttyfast')
|
||||
|
||||
" undo
|
||||
set undolevels=200
|
||||
set undodir=~/.vimdid
|
||||
set undofile
|
||||
|
||||
" search
|
||||
set incsearch ignorecase smartcase hlsearch
|
||||
" do not substitute _globally_
|
||||
set nogdefault
|
||||
|
||||
set visualbell
|
||||
set wildmenu
|
||||
set showmatch
|
||||
|
||||
set pastetoggle=<F2>
|
||||
"prevent trackpad mis{click,touche}s
|
||||
set mouse=
|
||||
"set viminfo=
|
||||
|
||||
|
||||
" ==============================================================================
|
||||
" 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
|
||||
" `vim.lsp.buf.formatting_sync` is depricated
|
||||
" but it is still present until Debian switches to a compatible version
|
||||
"autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 200)
|
||||
autocmd BufWritePre *.rs lua vim.lsp.buf.format(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
|
||||
|
||||
luafile ~/.config/nvim/lua/simrat39__rust-tools.nvim.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
|
||||
|
||||
|
||||
" ==============================================================================
|
||||
" Statusline
|
||||
" ==============================================================================
|
||||
" Define all the different modes
|
||||
let g:currentmode={
|
||||
\ 'n' : 'NORMAL',
|
||||
\ 'no' : 'NORMAL·OPERATOR PENDING',
|
||||
\ 'v' : 'VISUAL',
|
||||
\ 'V' : 'V·LINE',
|
||||
\ '^V' : 'V·BLOCK',
|
||||
\ 's' : 'SELECT',
|
||||
\ 'S' : 'S·LINE',
|
||||
\ '^S' : 'S·BLOCK',
|
||||
\ 'i' : 'INSERT',
|
||||
\ 'R' : 'REPLACE',
|
||||
\ 'Rv' : 'V·REPLACE',
|
||||
\ 'c' : 'COMMAND',
|
||||
\ 'cv' : 'VIM EX',
|
||||
\ 'ce' : 'EX',
|
||||
\ 'r' : 'PROMPT',
|
||||
\ 'rm' : 'MORE',
|
||||
\ 'r?' : 'CONFIRM',
|
||||
\ '!' : 'SHELL',
|
||||
\ 't' : 'TERMINAL'
|
||||
\}
|
||||
|
||||
set statusline=
|
||||
" 2 space padding
|
||||
set statusline+=%#ErrorMsg#\ \
|
||||
" shows mode
|
||||
set statusline+=%#Search#\ %{g:currentmode[mode()]}\
|
||||
" shows '[+]' if modified else '[0]'
|
||||
set statusline+=%#ErrorMsg#\ %{&modified?'[+]':'[0]'}\
|
||||
" show if a file is readonly
|
||||
set statusline+=%#Question#%{&readonly?'[RO]':'[RW]'}\
|
||||
" show the file name
|
||||
set statusline+=%#CursorLineNr#\ %f\
|
||||
" show filename
|
||||
set statusline+=%#SignColumn#\(%{wordcount().words}\)\ %#Comment#
|
||||
" show wc
|
||||
set statusline+=%=
|
||||
" show file format dos/UNIX
|
||||
set statusline+=%#Title#%{&ff}\
|
||||
" show encoding format
|
||||
set statusline+=%#Directory#%{&fileencoding}\
|
||||
" show the syntax/file type eg Rust, C, Python, Vim etc
|
||||
set statusline+=%#Todo#\ %Y\
|
||||
" show percentage through a file
|
||||
set statusline+=%#Identifier#\ %p%%
|
||||
" show the currentline/totallines
|
||||
set statusline+=%#Normal#\ %lL\
|
||||
" show column number
|
||||
set statusline+=%#CursorColumn#\ %cC\
|
||||
" 2 space padding
|
||||
set statusline+=%#Normal#\ \
|
||||
set laststatus=2
|
||||
|
||||
|
||||
" ==============================================================================
|
||||
" key bindings
|
||||
" ==============================================================================
|
||||
" Jump to start and end of line using the home row keys
|
||||
map H ^
|
||||
map L $
|
||||
|
||||
" remap uppercase J and K to their lowercase counterparts;
|
||||
" been bitten too many times
|
||||
nnoremap K k
|
||||
nnoremap J j
|
||||
"inoremap K k
|
||||
"inoremap J j
|
||||
|
||||
"map-command [map-arg] {lhs} {rhs}
|
||||
nnoremap <C-J> <C-W><C-J>
|
||||
nnoremap <C-K> <C-W><C-K>
|
||||
nnoremap <C-L> <C-W><C-L>
|
||||
nnoremap <C-H> <C-W><C-H>
|
||||
|
||||
" neovide (GUI) clipboard
|
||||
nnoremap <C-S-V> "+P
|
||||
" handle Ctrl+Shift+V in GUI somehow
|
||||
" inoremap <C-S-V> "+P
|
||||
|
||||
|
||||
" 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}
|
|
@ -0,0 +1,28 @@
|
|||
-- CursorHold
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
pattern = "*",
|
||||
command = "lua vim.diagnostic.open_float(nil, { focusable = false })",
|
||||
})
|
||||
|
||||
|
||||
-- format on write
|
||||
vim.g.rustfmt_autosave = 1
|
||||
vim.g.rustfmt_emit_files = 1
|
||||
vim.g.rustfmt_fail_silently = 0
|
||||
vim.api.nvim_create_autocmd({"BufWritePre"}, {
|
||||
pattern = {"*.rs"},
|
||||
command = "lua vim.lsp.buf.format(nil, 200)",
|
||||
})
|
||||
|
||||
-- run `cargo run` upon `:w`
|
||||
vim.api.nvim_create_autocmd({"BufWritePost"}, {
|
||||
pattern = {"*.rs"},
|
||||
command = "!cargo run",
|
||||
})
|
||||
|
||||
|
||||
-- indentation (2 spaces)
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = {"*.lua"},
|
||||
command = "setlocal expandtab shiftwidth=2 softtabstop=2",
|
||||
})
|
|
@ -1,34 +0,0 @@
|
|||
local cmp = require'cmp'
|
||||
cmp.setup({
|
||||
-- Enable LSP snippets
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body)
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
-- Up arrow key or 'Ctrl + p' to select next item
|
||||
['<Up>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
-- Down arrow key or 'Ctrl + n' to select next item
|
||||
['<Down>'] = cmp.mapping.select_next_item(),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
-- Tab key to select current item
|
||||
['<Tab>'] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Insert,
|
||||
select = true,
|
||||
}),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.close(),
|
||||
},
|
||||
|
||||
-- Installed sources
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'vsnip' },
|
||||
{ name = 'path' },
|
||||
{ name = 'buffer' },
|
||||
},
|
||||
})
|
|
@ -0,0 +1,14 @@
|
|||
-- Jump to start and end of line using the home row keys
|
||||
vim.keymap.set("n", "H", "^")
|
||||
vim.keymap.set("n", "L", "$")
|
||||
|
||||
-- remap uppercase J and K to their lowercase counterparts;
|
||||
-- been bitten too many times
|
||||
vim.keymap.set("n", "J", "j")
|
||||
vim.keymap.set("n", "K", "k")
|
||||
|
||||
-- move between buffers using Ctrl+[h,j,k,l]
|
||||
vim.keymap.set({"n", "v", "i", "c"}, "<C-H>", "<C-W><C-H>")
|
||||
|
||||
-- neovide (GUI) clipboard
|
||||
vim.keymap.set({"n", "i"}, "<C-S-V>", "\"+P")
|
|
@ -0,0 +1,80 @@
|
|||
--------------------------------------------------------------------------------
|
||||
-- Packer related setup
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- This section is HEAVILY "inspired" by this guide
|
||||
-- https://www.chiarulli.me/Neovim-2/03-plugins/
|
||||
|
||||
-- Use a protected call so that we do not error out on the first use
|
||||
local status_ok, packer = pcall(require, "packer")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
-- Have Packer use a pop-up window
|
||||
packer.init({
|
||||
display = {
|
||||
open_fn = function()
|
||||
return require("packer.util").float({
|
||||
border = "single"
|
||||
})
|
||||
end
|
||||
}}
|
||||
)
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Install packages
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
return require("packer").startup(function(use)
|
||||
-- Packer can manage itself
|
||||
use "wbthomason/packer.nvim"
|
||||
|
||||
-- decorations
|
||||
use {
|
||||
"chriskempson/base16-vim"
|
||||
}
|
||||
|
||||
-- plugins for finding stuff
|
||||
use {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-telescope/telescope.nvim",
|
||||
"jremmen/vim-ripgrep",
|
||||
}
|
||||
|
||||
-- auto-complete
|
||||
use {
|
||||
"neovim/nvim-lspconfig",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"hrsh7th/nvim-cmp",
|
||||
"hrsh7th/cmp-vsnip",
|
||||
"hrsh7th/vim-vsnip",
|
||||
}
|
||||
|
||||
-- parser/highlighter
|
||||
use { "nvim-treesitter/nvim-treesitter", cmd = "TSUpdate" }
|
||||
|
||||
-- Rust lang
|
||||
use {
|
||||
"rust-lang/rust.vim",
|
||||
"simrat39/rust-tools.nvim",
|
||||
}
|
||||
|
||||
-- git
|
||||
use "tpope/vim-fugitive"
|
||||
|
||||
-- tree view
|
||||
use {
|
||||
"nvim-tree/nvim-tree.lua",
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
}
|
||||
|
||||
|
||||
if PACKER_BOOTSTRAP then
|
||||
require("packer").sync()
|
||||
end
|
||||
end)
|
|
@ -1,3 +1,112 @@
|
|||
--------------------------------------------------------------------------------
|
||||
-- nvim-tree setup
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
require("nvim-tree").setup({
|
||||
auto_reload_on_write = true,
|
||||
disable_netrw = false,
|
||||
hijack_netrw = true,
|
||||
sort_by = "case_sensitive",
|
||||
view = {
|
||||
width = 30,
|
||||
number = true,
|
||||
relativenumber = true,
|
||||
mappings = {
|
||||
list = {
|
||||
{ key = "u", action = "dir_up" },
|
||||
},
|
||||
},
|
||||
},
|
||||
renderer = {
|
||||
group_empty = false,
|
||||
highlight_git = true,
|
||||
icons = {
|
||||
symlink_arrow = " ➛ ",
|
||||
glyphs = {
|
||||
modified = "●",
|
||||
git = {
|
||||
unstaged = "✗",
|
||||
staged = "✓",
|
||||
unmerged = "",
|
||||
renamed = "➜",
|
||||
untracked = "[ ]",
|
||||
deleted = "",
|
||||
ignored = "◌",
|
||||
},
|
||||
},
|
||||
},
|
||||
special_files = { "Cargo.toml", "README.md", "Readme.md", "readme.md" },
|
||||
symlink_destination = true,
|
||||
},
|
||||
filters = {
|
||||
dotfiles = true,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
-- open nvim-tree
|
||||
-- this function checks if all of the arguments provided to Neovim
|
||||
-- are either file(s) or director(y|ies)
|
||||
-- returns true only if an argv is file
|
||||
function dir_or_file()
|
||||
local iter = 0
|
||||
while iter < vim.fn.argc() do
|
||||
local fpath = io.open(vim.fn.argv(iter), "r")
|
||||
iter = iter + 1
|
||||
if fpath ~= nil then
|
||||
io.close(fpath)
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- open the tree if no files are specified in argv
|
||||
local open_tree = dir_or_file()
|
||||
if open_tree ~= true then
|
||||
require("nvim-tree.api").tree.open()
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- nvim-cmp setup
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- Set up nvim-cmp.
|
||||
local cmp = require'cmp'
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
-- REQUIRED - you must specify a snippet engine
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||
end,
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<Tab>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'vsnip' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
require("lspconfig")["rust_analyzer"].setup {
|
||||
cmd = {"rust-analyzer"},
|
||||
filetypes = {"rust"},
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- rust-tools.nvim setup
|
||||
--------------------------------------------------------------------------------
|
||||
local opts = {
|
||||
tools = { -- rust-tools options
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
--------------------------------------------------------------------------------
|
||||
-- initial setup
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- disable netrw at the very start of init.lua (strongly advised by _nvim-tree.lua_)
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Plugin setup
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- ensure that packer is installed
|
||||
if vim.fn.empty(vim.fn.glob(vim.fn.stdpath("data").."/site/pack/packer/start/packer.nvim")) > 0 then
|
||||
PACKER_BOOTSTRAP = vim.fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--depth",
|
||||
"1",
|
||||
"https://github.com/wbthomason/packer.nvim",
|
||||
"~/.local/share/nvim/site/pack/packer/start/packer.nvim",
|
||||
})
|
||||
print("Packer installed. Please close and re-open Neovim.");
|
||||
end
|
||||
|
||||
-- Autocommand that reloads Neovim whenever the "plugins.lua" file is saved
|
||||
|
||||
|
||||
-- 'nvim-tree.lua' setup
|
||||
require("nvim-tree").setup({
|
||||
auto_reload_on_write = true,
|
||||
disable_netrw = false,
|
||||
hijack_netrw = true,
|
||||
sort_by = "case_sensitive",
|
||||
view = {
|
||||
width = 30,
|
||||
number = true,
|
||||
relativenumber = true,
|
||||
mappings = {
|
||||
list = {
|
||||
{ key = "u", action = "dir_up" },
|
||||
},
|
||||
},
|
||||
},
|
||||
renderer = {
|
||||
group_empty = false,
|
||||
highlight_git = true,
|
||||
icons = {
|
||||
symlink_arrow = " ➛ ",
|
||||
glyphs = {
|
||||
modified = "●",
|
||||
git = {
|
||||
unstaged = "✗",
|
||||
staged = "✓",
|
||||
unmerged = "",
|
||||
renamed = "➜",
|
||||
untracked = "[ ]",
|
||||
deleted = "",
|
||||
ignored = "◌",
|
||||
},
|
||||
},
|
||||
},
|
||||
special_files = { "Cargo.toml", "README.md", "Readme.md", "readme.md" },
|
||||
symlink_destination = true,
|
||||
},
|
||||
filters = {
|
||||
dotfiles = true,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- open _things_...
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
local function open_nvim_tree()
|
||||
require("nvim-tree.api").tree.open()
|
||||
end
|
||||
|
||||
-- UNDO THIS open_nvim_tree()
|
|
@ -1,67 +0,0 @@
|
|||
--------------------------------------------------------------------------------
|
||||
-- initial setup
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- disable netrw at the very start of init.lua (strongly advised by _nvim-tree.lua_)
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Plugin setup
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
-- 'nvim-tree.lua' setup
|
||||
require("nvim-tree").setup({
|
||||
auto_reload_on_write = true,
|
||||
disable_netrw = false,
|
||||
hijack_netrw = true,
|
||||
sort_by = "case_sensitive",
|
||||
view = {
|
||||
width = 30,
|
||||
number = true,
|
||||
relativenumber = true,
|
||||
mappings = {
|
||||
list = {
|
||||
{ key = "u", action = "dir_up" },
|
||||
},
|
||||
},
|
||||
},
|
||||
renderer = {
|
||||
group_empty = false,
|
||||
highlight_git = true,
|
||||
icons = {
|
||||
symlink_arrow = " ➛ ",
|
||||
glyphs = {
|
||||
modified = "●",
|
||||
git = {
|
||||
unstaged = "✗",
|
||||
staged = "✓",
|
||||
unmerged = "",
|
||||
renamed = "➜",
|
||||
untracked = "[ ]",
|
||||
deleted = "",
|
||||
ignored = "◌",
|
||||
},
|
||||
},
|
||||
},
|
||||
special_files = { "Cargo.toml", "README.md", "Readme.md", "readme.md" },
|
||||
symlink_destination = true,
|
||||
},
|
||||
filters = {
|
||||
dotfiles = true,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- open _things_...
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
local function open_nvim_tree()
|
||||
require("nvim-tree.api").tree.open()
|
||||
end
|
||||
|
||||
-- UNDO THIS open_nvim_tree()
|
|
@ -0,0 +1,64 @@
|
|||
" ==============================================================================
|
||||
" Vimscript things that I can't "rewrite" in Lua
|
||||
" ==============================================================================
|
||||
|
||||
syntax on
|
||||
filetype plugin indent on
|
||||
set encoding=utf-8
|
||||
|
||||
|
||||
" appearance
|
||||
set colorcolumn=80
|
||||
set cursorcolumn
|
||||
set autoindent expandtab tabstop=4 shiftwidth=4 "softtabstop=4
|
||||
set number relativenumber
|
||||
set noshowmode " I will set the status line manually; Neovim doesn't need to show this
|
||||
set showcmd
|
||||
set spell
|
||||
set termguicolors
|
||||
set cursorline
|
||||
set title
|
||||
set showmatch
|
||||
set splitright
|
||||
|
||||
let base16colorspace=256
|
||||
colorscheme base16-google-dark
|
||||
|
||||
|
||||
" speed/other improvements
|
||||
set timeoutlen=300 " http://stackoverflow.com/questions/2158516/delay-before-o-opens-a-new-line
|
||||
set updatetime=300 " updatetime for CursorHold
|
||||
set noswapfile
|
||||
set wildmenu " use <Tab> to auto-complete Neovim commands
|
||||
|
||||
" have a fixed column for diagnostics to appear in; this removes the jigger when warnings/errors flow in
|
||||
set signcolumn=yes
|
||||
|
||||
" auto completion
|
||||
" :help completeopt
|
||||
" menuone: popup even when there's only one match
|
||||
" preview: show extra information about the currently selected completion
|
||||
" noinsert: do not insert text until a selection is made
|
||||
" noselect: do not select, force the user to select one from the menu
|
||||
set completeopt=menuone,preview,noinsert,noselect
|
||||
|
||||
" disable messages like 'match 1 of 2', 'the only match', 'pattern not found', etc
|
||||
set shortmess+=c
|
||||
|
||||
" undo
|
||||
set undolevels=200
|
||||
set undodir=~/.vimdid
|
||||
set undofile
|
||||
|
||||
|
||||
" search and/or replace
|
||||
set incsearch ignorecase smartcase hlsearch
|
||||
set nogdefault
|
||||
|
||||
|
||||
" disable mouse
|
||||
set mouse=
|
||||
|
||||
|
||||
" change highlight color when yanking
|
||||
au TextYankPost * silent! lua vim.highlight.on_yank {higroup="Visual", timeout=250}
|
|
@ -0,0 +1,53 @@
|
|||
" Define all the different modes
|
||||
let g:currentmode={
|
||||
\ 'n' : 'NORMAL',
|
||||
\ 'no' : 'NORMAL·OPERATOR PENDING',
|
||||
\ 'v' : 'VISUAL',
|
||||
\ 'V' : 'V·LINE',
|
||||
\ '' : 'V·BLOCK',
|
||||
\ 's' : 'SELECT',
|
||||
\ 'S' : 'S·LINE',
|
||||
\ '^S' : 'S·BLOCK',
|
||||
\ 'i' : 'INSERT',
|
||||
\ 'R' : 'REPLACE',
|
||||
\ 'Rv' : 'V·REPLACE',
|
||||
\ 'c' : 'COMMAND',
|
||||
\ 'cv' : 'VIM EX',
|
||||
\ 'ce' : 'EX',
|
||||
\ 'r' : 'PROMPT',
|
||||
\ 'rm' : 'MORE',
|
||||
\ 'r?' : 'CONFIRM',
|
||||
\ '!' : 'SHELL',
|
||||
\ 't' : 'TERMINAL'
|
||||
\}
|
||||
|
||||
set statusline=
|
||||
" 2 space padding
|
||||
set statusline+=%#ErrorMsg#\ \
|
||||
" shows mode
|
||||
set statusline+=%#Search#\ %{g:currentmode[mode()]}\
|
||||
" shows '[+]' if modified else '[0]'
|
||||
set statusline+=%#ErrorMsg#\ %{&modified?'[+]':'[0]'}\
|
||||
" show if a file is readonly
|
||||
set statusline+=%#Question#%{&readonly?'[RO]':'[RW]'}\
|
||||
" show the file name
|
||||
set statusline+=%#CursorLineNr#\ %f\
|
||||
" show filename
|
||||
set statusline+=%#SignColumn#\(%{wordcount().words}\)\ %#Comment#
|
||||
" show wc
|
||||
set statusline+=%=
|
||||
" show file format dos/UNIX
|
||||
set statusline+=%#Title#%{&ff}\
|
||||
" show encoding format
|
||||
set statusline+=%#Directory#%{&fileencoding}\
|
||||
" show the syntax/file type eg Rust, C, Python, Vim etc
|
||||
set statusline+=%#Todo#\ %Y\
|
||||
" show percentage through a file
|
||||
set statusline+=%#Identifier#\ %p%%
|
||||
" show the currentline/totallines
|
||||
set statusline+=%#Normal#\ %lL\
|
||||
" show column number
|
||||
set statusline+=%#CursorColumn#\ %cC\
|
||||
" 2 space padding
|
||||
set statusline+=%#Normal#\ \
|
||||
set laststatus=2
|
|
@ -7,3 +7,6 @@ Thumbs.db
|
|||
|
||||
# compiled C/C++ files
|
||||
*.out
|
||||
|
||||
# Packer.nvim related file
|
||||
.config/nvim/plugin/packer_compiled.lua
|
||||
|
|
Loading…
Reference in New Issue