nvim ref to lua
This commit is contained in:
parent
04993a0e51
commit
a7669555a8
2
.gitignore
vendored
2
.gitignore
vendored
@ -5,3 +5,5 @@ sub/bash/bashrc.d/*
|
|||||||
sub/zsh/zshrc.d/*
|
sub/zsh/zshrc.d/*
|
||||||
!sub/zsh/zshrc.d/00_test.sh
|
!sub/zsh/zshrc.d/00_test.sh
|
||||||
sub/vim/tmp/
|
sub/vim/tmp/
|
||||||
|
|
||||||
|
sub/nvim/plugin
|
||||||
|
|||||||
14
Makefile
14
Makefile
@ -36,18 +36,14 @@ alacritty:
|
|||||||
mkdir -p ~/.config/alacritty
|
mkdir -p ~/.config/alacritty
|
||||||
ln -s $(PWD)/sub/alacritty/alacritty.yml ~/.config/alacritty/
|
ln -s $(PWD)/sub/alacritty/alacritty.yml ~/.config/alacritty/
|
||||||
|
|
||||||
vim:
|
nvim:
|
||||||
@echo "sudo pacman -S npm ctags fzf glow; mkdir ~/.npm-global; npm config set prefix '~/.npm-global'; npm install -g pyright"
|
@echo "sudo pacman -S npm ctags fzf glow; mkdir ~/.npm-global; npm config set prefix '~/.npm-global'; npm install -g pyright"
|
||||||
echo "set editing-mode vi" >> ~/.inputrc
|
echo "set editing-mode vi" >> ~/.inputrc
|
||||||
test -d ~/.vim || \
|
test -d ~/.config/nvim || \
|
||||||
ln -s $(PWD)/sub/vim ~/.vim
|
ln -s $(PWD)/sub/nvim ~/.config/nvim
|
||||||
ln -s $(PWD)/light/.vimrc ~/.vimrc
|
|
||||||
mkdir -p ~/.config/nvim/lua
|
|
||||||
ln -s ~/.vim/vimrc ~/.config/nvim/init.vim
|
|
||||||
ln -s $(PWD)/functions/vim_askpass_helper ~/.local/bin
|
ln -s $(PWD)/functions/vim_askpass_helper ~/.local/bin
|
||||||
ln -s $(PWD)/sub/vim/init.lua ~/.config/nvim/lua/init.lua
|
git clone --depth 1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim
|
||||||
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
|
nvim +PackerCompile +PackerClean +PackerInstall +PackerUpdate +qall
|
||||||
nvim +PluginInstall +qall
|
|
||||||
|
|
||||||
ssh:
|
ssh:
|
||||||
cat $(PWD)/sub/ssh/config >> ~/.ssh/config
|
cat $(PWD)/sub/ssh/config >> ~/.ssh/config
|
||||||
|
|||||||
40
sub/nvim/after/plugin/auto-save.lua
Normal file
40
sub/nvim/after/plugin/auto-save.lua
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
|
||||||
|
local status, autosave = pcall(require, "auto-save")
|
||||||
|
if (not status) then return end
|
||||||
|
|
||||||
|
autosave.setup(
|
||||||
|
{
|
||||||
|
enabled = true, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it)
|
||||||
|
execution_message = {
|
||||||
|
message = function() -- message to print on save
|
||||||
|
return ("AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"))
|
||||||
|
end,
|
||||||
|
dim = 0.18, -- dim the color of `message`
|
||||||
|
cleaning_interval = 1250, -- (milliseconds) automatically clean MsgArea after displaying `message`. See :h MsgArea
|
||||||
|
},
|
||||||
|
trigger_events = {"InsertLeave", "TextChanged"}, -- vim events that trigger auto-save. See :h events
|
||||||
|
-- function that determines whether to save the current buffer or not
|
||||||
|
-- return true: if buffer is ok to be saved
|
||||||
|
-- return false: if it's not ok to be saved
|
||||||
|
condition = function(buf)
|
||||||
|
local fn = vim.fn
|
||||||
|
local utils = require("auto-save.utils.data")
|
||||||
|
|
||||||
|
if
|
||||||
|
fn.getbufvar(buf, "&modifiable") == 1 and
|
||||||
|
utils.not_in(fn.getbufvar(buf, "&filetype"), {}) then
|
||||||
|
return true -- met condition(s), can save
|
||||||
|
end
|
||||||
|
return false -- can't save
|
||||||
|
end,
|
||||||
|
write_all_buffers = false, -- write all buffers when the current one meets `condition`
|
||||||
|
debounce_delay = 135, -- saves the file at most every `debounce_delay` milliseconds
|
||||||
|
callbacks = { -- functions to be executed at different intervals
|
||||||
|
enabling = nil, -- ran when enabling auto-save
|
||||||
|
disabling = nil, -- ran when disabling auto-save
|
||||||
|
before_asserting_save = nil, -- ran before checking `condition`
|
||||||
|
before_saving = nil, -- ran before doing the actual save
|
||||||
|
after_saving = nil -- ran after doing the actual save
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
51
sub/nvim/after/plugin/cmp.lua
Normal file
51
sub/nvim/after/plugin/cmp.lua
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
local status, cmp = pcall(require, "cmp")
|
||||||
|
if (not status) then return end
|
||||||
|
|
||||||
|
|
||||||
|
-- nvim-cmp setup
|
||||||
|
local cmp = require 'cmp'
|
||||||
|
cmp.setup {
|
||||||
|
completion = {
|
||||||
|
autocomplete = false
|
||||||
|
},
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
require('luasnip').lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = {
|
||||||
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||||
|
['<C-n>'] = 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.Replace,
|
||||||
|
select = true,
|
||||||
|
},
|
||||||
|
['<Tab>'] = function(fallback)
|
||||||
|
if vim.fn.pumvisible() == 1 then
|
||||||
|
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-n>', true, true, true), 'n')
|
||||||
|
elseif luasnip.expand_or_jumpable() then
|
||||||
|
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true), '')
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
['<S-Tab>'] = function(fallback)
|
||||||
|
if vim.fn.pumvisible() == 1 then
|
||||||
|
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-p>', true, true, true), 'n')
|
||||||
|
elseif luasnip.jumpable(-1) then
|
||||||
|
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-jump-prev', true, true, true), '')
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'luasnip' },
|
||||||
|
},
|
||||||
|
}
|
||||||
3
sub/nvim/after/plugin/colorscheme.lua
Normal file
3
sub/nvim/after/plugin/colorscheme.lua
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
|
vim.api.nvim_exec('colorscheme gruvbox', true)
|
||||||
5
sub/nvim/after/plugin/gitsigns.lua
Normal file
5
sub/nvim/after/plugin/gitsigns.lua
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
local status, gitsigns = pcall(require, "gitsigns")
|
||||||
|
if (not status) then return end
|
||||||
|
|
||||||
|
gitsigns.setup()
|
||||||
50
sub/nvim/after/plugin/lspconfig.lua
Normal file
50
sub/nvim/after/plugin/lspconfig.lua
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
|
||||||
|
local status, nvim_lsp = pcall(require, "lspconfig")
|
||||||
|
if (not status) then return end
|
||||||
|
|
||||||
|
|
||||||
|
-- Use an on_attach function to only map the following keys
|
||||||
|
-- after the language server attaches to the current buffer
|
||||||
|
local on_attach = function(client, bufnr)
|
||||||
|
|
||||||
|
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
||||||
|
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||||
|
|
||||||
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
|
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
|
|
||||||
|
-- Mappings.
|
||||||
|
local opts = { noremap=true, silent=true }
|
||||||
|
|
||||||
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
|
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||||
|
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||||
|
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||||
|
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||||
|
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||||
|
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Use a loop to conveniently call 'setup' on multiple servers and
|
||||||
|
-- map buffer local keybindings when the language server attaches
|
||||||
|
local servers = { 'pyright' }
|
||||||
|
for _, lsp in ipairs(servers) do
|
||||||
|
nvim_lsp[lsp].setup {
|
||||||
|
on_attach = on_attach,
|
||||||
|
flags = {
|
||||||
|
debounce_text_changes = 150,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
5
sub/nvim/after/plugin/lualine.lua
Normal file
5
sub/nvim/after/plugin/lualine.lua
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
local status, lualine = pcall(require, "lualine")
|
||||||
|
if (not status) then return end
|
||||||
|
|
||||||
|
lualine.setup()
|
||||||
4
sub/nvim/after/plugin/luasnip.lua
Normal file
4
sub/nvim/after/plugin/luasnip.lua
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
local status, luasnip = pcall(require, "luasnip")
|
||||||
|
if (not status) then return end
|
||||||
|
|
||||||
5
sub/nvim/after/plugin/nvim-autopairs.lua
Normal file
5
sub/nvim/after/plugin/nvim-autopairs.lua
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
local status, nvim_autopairs = pcall(require, "nvim_autopairs")
|
||||||
|
if (not status) then return end
|
||||||
|
|
||||||
|
nvim_autopairs.setup()
|
||||||
8
sub/nvim/after/plugin/nvim-treesitter.lua
Normal file
8
sub/nvim/after/plugin/nvim-treesitter.lua
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
local status, nvim_treesitter = pcall(require, "nvim_treesitter")
|
||||||
|
if (not status) then return end
|
||||||
|
|
||||||
|
nvim_treesitter.setup {
|
||||||
|
auto_install = true,
|
||||||
|
}
|
||||||
|
|
||||||
6
sub/nvim/after/plugin/nvim-ts-autotag.lua
Normal file
6
sub/nvim/after/plugin/nvim-ts-autotag.lua
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
local status, nvim_ts_autotag = pcall(require, "nvim_ts_autotag")
|
||||||
|
if (not status) then return end
|
||||||
|
|
||||||
|
|
||||||
|
nvim_ts_autotag.setup()
|
||||||
10
sub/nvim/after/plugin/rainbow.lua
Normal file
10
sub/nvim/after/plugin/rainbow.lua
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
vim.api.nvim_exec([[
|
||||||
|
let g:rainbow_active = 1
|
||||||
|
]], true)
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd('FileType',
|
||||||
|
{
|
||||||
|
pattern = {"*"},
|
||||||
|
command = 'RainbowToggle'
|
||||||
|
})
|
||||||
5
sub/nvim/after/plugin/telescope.lua
Normal file
5
sub/nvim/after/plugin/telescope.lua
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
local status, telescope = pcall(require, "telescope")
|
||||||
|
if (not status) then return end
|
||||||
|
|
||||||
|
telescope.load_extension('fzf')
|
||||||
4
sub/nvim/init.lua
Normal file
4
sub/nvim/init.lua
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
require("base.sourcer")
|
||||||
|
|
||||||
|
|
||||||
85
sub/nvim/lua/base/base.lua
Normal file
85
sub/nvim/lua/base/base.lua
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
|
||||||
|
vim.opt.ruler = true
|
||||||
|
|
||||||
|
|
||||||
|
vim.scriptencoding = 'utf-8'
|
||||||
|
vim.opt.encoding = 'utf-8'
|
||||||
|
vim.opt.fileencoding = 'utf-8'
|
||||||
|
|
||||||
|
vim.opt.clipboard = 'unnamedplus'
|
||||||
|
vim.opt.shell = 'bash'
|
||||||
|
|
||||||
|
vim.opt.ttimeoutlen = 0
|
||||||
|
|
||||||
|
-- vim.opt.compatible = false
|
||||||
|
|
||||||
|
vim.opt.expandtab = true
|
||||||
|
vim.opt.smarttab = true
|
||||||
|
vim.opt.tabstop = 4
|
||||||
|
|
||||||
|
|
||||||
|
vim.opt.softtabstop = 4
|
||||||
|
vim.opt.shiftwidth = 4
|
||||||
|
vim.opt.autoindent = true
|
||||||
|
vim.opt.smartindent = true
|
||||||
|
vim.opt.wrap = false
|
||||||
|
|
||||||
|
vim.opt.ttyfast = true
|
||||||
|
vim.opt.autoread = true
|
||||||
|
|
||||||
|
|
||||||
|
vim.opt.errorbells = false
|
||||||
|
vim.opt.visualbell = false
|
||||||
|
vim.opt.showcmd = true
|
||||||
|
vim.opt.showtabline = 2
|
||||||
|
|
||||||
|
vim.opt.smartcase = true
|
||||||
|
vim.opt.incsearch = true
|
||||||
|
|
||||||
|
vim.opt.mousehide = true
|
||||||
|
vim.opt.mouse = 'a'
|
||||||
|
|
||||||
|
vim.opt.colorcolumn = '81'
|
||||||
|
vim.opt.scrolloff = 7
|
||||||
|
|
||||||
|
vim.opt.backup = true
|
||||||
|
vim.opt.swapfile = false
|
||||||
|
vim.opt.undofile = true
|
||||||
|
vim.opt.history = 1000
|
||||||
|
vim.opt.undoreload = 1000
|
||||||
|
vim.opt.backupdir = '~/.vim/tmp/backup/'
|
||||||
|
vim.opt.undodir = '~/.vim/tmp/undo/'
|
||||||
|
vim.opt.directory = '~/.vim/tmp/swap/'
|
||||||
|
|
||||||
|
vim.api.nvim_exec([[
|
||||||
|
function! MakeDirIfNoExists(path)
|
||||||
|
if !isdirectory(expand(a:path))
|
||||||
|
call mkdir(expand(a:path), "p")
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
" make this dirs if no exists previously
|
||||||
|
silent! call MakeDirIfNoExists(&undodir)
|
||||||
|
silent! call MakeDirIfNoExists(&backupdir)
|
||||||
|
silent! call MakeDirIfNoExists(&directory)
|
||||||
|
]], true)
|
||||||
|
|
||||||
|
vim.opt.ffs = 'unix,mac'
|
||||||
|
|
||||||
|
vim.opt.path:append { '**' } -- Finding files - Search down into subfolders
|
||||||
|
|
||||||
|
vim.opt.cursorline = true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
vim.cmd([[let &t_SI.="\e[5 q"]])
|
||||||
|
vim.cmd([[let &t_SR.="\e[3 q"]])
|
||||||
|
vim.cmd([[let &t_EI.="\e[1 q"]])
|
||||||
|
|
||||||
|
|
||||||
|
vim.cmd([[let g:netrw_banner = 0]]) -- hide banner
|
||||||
|
vim.cmd([[let g:netrw_liststyle = 3]]) -- tree instead of plain view
|
||||||
|
vim.cmd([[let g:netrw_browse_split = 0]])
|
||||||
|
vim.cmd([[let g:netrw_winsize = 15]])
|
||||||
|
vim.cmd([[let g:netrw_keepdir = 0]])
|
||||||
125
sub/nvim/lua/base/maps.lua
Normal file
125
sub/nvim/lua/base/maps.lua
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
local keymap = vim.keymap
|
||||||
|
|
||||||
|
|
||||||
|
vim.g.mapleader = ','
|
||||||
|
|
||||||
|
|
||||||
|
vim.api.nvim_exec([[
|
||||||
|
" like tabdo but restore the current tab
|
||||||
|
function! TabDo(command)
|
||||||
|
let currTab=tabpagenr()
|
||||||
|
execute 'tabdo ' . a:command
|
||||||
|
execute 'tabn ' . currTab
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" like bufdo but restore the current buffer
|
||||||
|
function! BufDo(command)
|
||||||
|
let currBuff=bufnr("%")
|
||||||
|
execute 'bufdo ' . a:command
|
||||||
|
execute 'buffer ' . currBuff
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" like windo but restore the current window
|
||||||
|
function! WinDo(command)
|
||||||
|
let currwin=winnr()
|
||||||
|
execute 'windo ' . a:command
|
||||||
|
execute currwin . 'wincmd w'
|
||||||
|
endfunction
|
||||||
|
]], true)
|
||||||
|
|
||||||
|
keymap.set('n', '<Leader>c', [[:call TabDo('set cursorline!')<CR>]], {silent = true})
|
||||||
|
|
||||||
|
keymap.set('n', '<Leader>/', [[:set invhlsearch<CR>]], {silent = true})
|
||||||
|
|
||||||
|
keymap.set('i', 'jk', '<ESC>')
|
||||||
|
keymap.set('i', 'ол', '<ESC>')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- x to blackhole
|
||||||
|
keymap.set('n', 'x', '"_x')
|
||||||
|
|
||||||
|
-- Increment/decrement
|
||||||
|
keymap.set('n', '+', '<C-a>')
|
||||||
|
keymap.set('n', '-', '<C-x>')
|
||||||
|
|
||||||
|
-- Select all
|
||||||
|
keymap.set('n', '<C-a>', 'gg<S-v>G')
|
||||||
|
|
||||||
|
|
||||||
|
-- Scroll tabs
|
||||||
|
keymap.set("n", '<C-l>', ':tabnext<CR>')
|
||||||
|
keymap.set("n", '<C-h>', ':tabprev<CR>')
|
||||||
|
|
||||||
|
|
||||||
|
-- Kill current buffer
|
||||||
|
keymap.set("n", '<Leader>qq', ':bd!<CR>')
|
||||||
|
-- Quick exit without saving
|
||||||
|
keymap.set("n", '<Leader>qa', ':qa!<CR>')
|
||||||
|
|
||||||
|
|
||||||
|
keymap.set("n", '<Leader>eh', ':set list!<CR>')
|
||||||
|
vim.opt.listchars=[[tab:→\ ,eol:↵,trail:·,extends:↷,precedes:↶]]
|
||||||
|
|
||||||
|
|
||||||
|
-- Tags panes (ctags required)
|
||||||
|
keymap.set("n", '<Leader>t', ':TagbarToggle<CR>')
|
||||||
|
|
||||||
|
|
||||||
|
-- Telescope
|
||||||
|
keymap.set("n", '<Leader>ff', '<cmd>Telescope find_files<CR>')
|
||||||
|
keymap.set("n", '<Leader>fg', '<cmd>Telescope live_grep<CR>')
|
||||||
|
|
||||||
|
|
||||||
|
-- Expand %% to dirname of current file in command line
|
||||||
|
keymap.set("c", '%%', [[getcmdtype() == ':' ? expand('%:h').'/' : '%%']], {expr = true})
|
||||||
|
|
||||||
|
|
||||||
|
-- Save from root
|
||||||
|
vim.api.nvim_create_user_command('Sw', [[execute 'silent! write !SUDO_ASKPASS=$(which vim_askpass_helper) sudo -A tee % >/dev/null']], {})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function create_autocmd_filetype(func)
|
||||||
|
create_autocmd = vim.api.nvim_create_autocmd
|
||||||
|
|
||||||
|
create_autocmd("BufEnter",
|
||||||
|
{ pattern = '*', callback = func}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
function set_keymap_run_script()
|
||||||
|
if vim.bo.filetype == 'python' then
|
||||||
|
cmd_string = string.format([[:tabnew %% <CR> :terminal %s %% <CR> :set nocursorline number norelativenumber <CR> G <CR>]], 'python3')
|
||||||
|
keymap.set("n", "<Leader>rr", cmd_string)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
create_autocmd_filetype(set_keymap_run_script)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Toggle line number style
|
||||||
|
vim.opt.number = true
|
||||||
|
vim.opt.relativenumber = true
|
||||||
|
|
||||||
|
vim.api.nvim_exec([[
|
||||||
|
function! ToggleRelativeAbsoluteNumber()
|
||||||
|
if !&number && !&relativenumber
|
||||||
|
set number
|
||||||
|
set norelativenumber
|
||||||
|
elseif &number && !&relativenumber
|
||||||
|
set nonumber
|
||||||
|
set relativenumber
|
||||||
|
elseif !&number && &relativenumber
|
||||||
|
set number
|
||||||
|
set relativenumber
|
||||||
|
elseif &number && &relativenumber
|
||||||
|
set nonumber
|
||||||
|
set norelativenumber
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
]], true)
|
||||||
|
|
||||||
|
keymap.set('n', '<Leader>l', [[:call TabDo('call ToggleRelativeAbsoluteNumber()') <CR>]], {silent = true})
|
||||||
45
sub/nvim/lua/base/plugins.lua
Normal file
45
sub/nvim/lua/base/plugins.lua
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
return require('packer').startup(function(use)
|
||||||
|
-- Packer can manage itself
|
||||||
|
use 'wbthomason/packer.nvim'
|
||||||
|
|
||||||
|
use 'VundleVim/Vundle.vim'
|
||||||
|
|
||||||
|
use {
|
||||||
|
'nvim-lualine/lualine.nvim',
|
||||||
|
requires = { 'kyazdani42/nvim-web-devicons', opt = true }
|
||||||
|
}
|
||||||
|
|
||||||
|
use 'morhetz/gruvbox'
|
||||||
|
use 'tpope/vim-surround'
|
||||||
|
use 'tpope/vim-commentary'
|
||||||
|
use 'ap/vim-css-color'
|
||||||
|
use 'preservim/tagbar'
|
||||||
|
use 'preservim/vimux'
|
||||||
|
use 'rbgrouleff/bclose.vim'
|
||||||
|
use 'frazrepo/vim-rainbow'
|
||||||
|
|
||||||
|
-- requiered patch your font
|
||||||
|
use 'ryanoasis/vim-devicons'
|
||||||
|
use 'powerman/vim-plugin-ruscmd' -- Russian navigation
|
||||||
|
|
||||||
|
use 'Pocco81/auto-save.nvim'
|
||||||
|
use 'windwp/nvim-autopairs'
|
||||||
|
|
||||||
|
-- pyright
|
||||||
|
use 'neovim/nvim-lspconfig'
|
||||||
|
use 'hrsh7th/nvim-cmp'
|
||||||
|
use 'hrsh7th/cmp-nvim-lsp'
|
||||||
|
use 'saadparwaiz1/cmp_luasnip'
|
||||||
|
use 'L3MON4D3/LuaSnip'
|
||||||
|
use 'nvim-lua/plenary.nvim'
|
||||||
|
|
||||||
|
use {
|
||||||
|
'nvim-telescope/telescope.nvim',
|
||||||
|
requires = { 'nvim-telescope/telescope-fzf-native.nvim', run = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build', opt = false }
|
||||||
|
}
|
||||||
|
use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' }
|
||||||
|
|
||||||
|
use 'lewis6991/gitsigns.nvim'
|
||||||
|
use 'windwp/nvim-ts-autotag'
|
||||||
|
|
||||||
|
end)
|
||||||
5
sub/nvim/lua/base/sourcer.lua
Normal file
5
sub/nvim/lua/base/sourcer.lua
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
require("base.base")
|
||||||
|
require("base.maps")
|
||||||
|
require("base.plugins")
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user