Add nvim lua config
This commit is contained in:
7
nvim/lua/basic.lua
Normal file
7
nvim/lua/basic.lua
Normal file
@ -0,0 +1,7 @@
|
||||
vim.opt.mouse = 'a'
|
||||
vim.opt.history = 1000
|
||||
vim.opt.ruler = true
|
||||
vim.opt.ruler = true
|
||||
vim.opt.number = true
|
||||
vim.opt.showcmd = true
|
||||
vim.opt.ttimeoutlen = 100
|
||||
47
nvim/lua/basic_vim.lua
Normal file
47
nvim/lua/basic_vim.lua
Normal file
@ -0,0 +1,47 @@
|
||||
vim.opt.mouse = 'a'
|
||||
vim.opt.history = 1000
|
||||
vim.opt.ruler = true
|
||||
vim.opt.ruler = true
|
||||
vim.opt.number = true
|
||||
vim.opt.showcmd = true
|
||||
vim.opt.ttimeoutlen = 100
|
||||
vim.opt.backspace = 'indent,eol,start'
|
||||
vim.opt.tabstop = 2
|
||||
vim.opt.expandtab = true
|
||||
vim.opt.shiftwidth = 2
|
||||
vim.opt.softtabstop = 2
|
||||
vim.opt.autoindent = true
|
||||
vim.opt.showmatch = true
|
||||
vim.opt.incsearch = true
|
||||
vim.opt.hlsearch = true
|
||||
vim.opt.wrapscan = true
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.smartcase = true
|
||||
vim.opt.hidden = true
|
||||
vim.opt.splitright = true
|
||||
vim.opt.splitbelow = true
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.wildmode = 'longest,list'
|
||||
vim.opt.wildignore = vim.opt.wildignore + 'main,*.o,*.d,*.aux,*.bbl,*.lof,*.loa,*.blg,*.fdb_latexmk,*.fls,*.tdo,*.pdf,*.pyc'
|
||||
vim.opt.spell = false
|
||||
vim.opt.foldmethod = 'syntax'
|
||||
vim.opt.foldopen = vim.opt.foldopen - 'block'
|
||||
vim.opt.foldlevel = 99
|
||||
vim.opt.lazyredraw = true
|
||||
vim.opt.listchars = 'eol:¬,tab:▸ ,trail:·'
|
||||
vim.opt.fillchars = 'vert:|,fold: '
|
||||
vim.opt.list = true
|
||||
vim.opt.laststatus = 2
|
||||
vim.opt.scrolloff = 8
|
||||
vim.opt.background = 'light'
|
||||
vim.opt.wrap = true
|
||||
vim.opt.showbreak = '..'
|
||||
-- vim.opt.clipboard = vim.opt.clipboard + 'unnamedplus'
|
||||
-- vim.opt.clipboard = 'unnamedplus'
|
||||
vim.opt.errorbells = false
|
||||
vim.opt.visualbell = true
|
||||
vim.opt.title = true
|
||||
vim.opt.autoread = true
|
||||
vim.opt.syntax = 'on'
|
||||
vim.opt.encoding = 'utf-8'
|
||||
vim.opt.completeopt = 'menu,menuone,noselect'
|
||||
17
nvim/lua/mappings_vim.lua
Normal file
17
nvim/lua/mappings_vim.lua
Normal file
@ -0,0 +1,17 @@
|
||||
-- Yanky mappings
|
||||
vim.keymap.set({"n","x"}, "p", "<Plug>(YankyPutAfter)")
|
||||
vim.keymap.set({"n","x"}, "P", "<Plug>(YankyPutBefore)")
|
||||
vim.keymap.set({"n","x"}, "gp", "<Plug>(YankyGPutAfter)")
|
||||
vim.keymap.set({"n","x"}, "gP", "<Plug>(YankyGPutBefore)")
|
||||
-- vim.keymap.set("n", "<c-n>", "<Plug>(YankyCycleForward)")
|
||||
-- vim.keymap.set("n", "<c-p>", "<Plug>(YankyCycleBackward)")
|
||||
vim.keymap.set({"n","x"}, "y", "<Plug>(YankyYank)")
|
||||
vim.keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<CR>")
|
||||
-- nnoremap <silent> <leader>f <cmd>Telescope find_files<CR>
|
||||
-- nnoremap <silent> <leader>fg <cmd>Telescope live_grep<CR>
|
||||
-- nnoremap <silent> <leader>o <cmd>Telescope buffers<CR>
|
||||
-- nnoremap <silent> <leader>fh <cmd>Telescope help_tags<CR>
|
||||
-- nnoremap <silent> <leader>F :e.<CR>
|
||||
-- nnoremap <silent> <leader>O :BufExplorer<CR>
|
||||
-- nnoremap <silent> <leader>t :CtrlPBufTagAll<CR>
|
||||
-- nnoremap <silent> <leader>T :TagbarToggle<CR>
|
||||
191
nvim/lua/plugins_vim.lua
Normal file
191
nvim/lua/plugins_vim.lua
Normal file
@ -0,0 +1,191 @@
|
||||
local Plug = vim.fn['plug#']
|
||||
|
||||
vim.call('plug#begin', '~/.local/share/nvim/site/plugins')
|
||||
|
||||
-- enhanced commenting
|
||||
Plug 'tpope/vim-commentary'
|
||||
-- enhanced single-repeat '.'
|
||||
Plug 'tpope/vim-repeat'
|
||||
-- enhanced surrounding
|
||||
Plug 'tpope/vim-surround'
|
||||
-- session management
|
||||
Plug 'tpope/vim-obsession'
|
||||
-- enhanced text objects
|
||||
Plug 'wellle/targets.vim'
|
||||
-- enhanced yank
|
||||
Plug 'gbprod/yanky.nvim'
|
||||
-- auto close brackets
|
||||
Plug 'Raimondi/delimitMate'
|
||||
-- start page
|
||||
Plug 'mhinz/vim-startify'
|
||||
-- alignment
|
||||
Plug 'junegunn/vim-easy-align'
|
||||
-- swap windows
|
||||
Plug 'wesQ3/vim-windowswap'
|
||||
|
||||
-- LSP
|
||||
Plug 'neovim/nvim-lspconfig'
|
||||
Plug('nvim-treesitter/nvim-treesitter', {['do'] = ':TSUpdate'})
|
||||
|
||||
-- command completion
|
||||
Plug 'hrsh7th/cmp-nvim-lsp'
|
||||
Plug 'hrsh7th/cmp-buffer'
|
||||
Plug 'hrsh7th/cmp-path'
|
||||
Plug 'hrsh7th/cmp-cmdline'
|
||||
Plug 'hrsh7th/nvim-cmp'
|
||||
-- prettify command completion
|
||||
Plug 'onsails/lspkind.nvim'
|
||||
|
||||
-- snippets
|
||||
Plug 'hrsh7th/cmp-vsnip'
|
||||
Plug 'hrsh7th/vim-vsnip'
|
||||
|
||||
-- fuzzy finder
|
||||
Plug 'nvim-lua/plenary.nvim'
|
||||
Plug('nvim-telescope/telescope.nvim', {branch = '0.1.x'})
|
||||
|
||||
-- status line and theme
|
||||
Plug 'bling/vim-airline'
|
||||
Plug 'vim-airline/vim-airline-themes'
|
||||
Plug 'jonathanfilip/vim-lucius'
|
||||
Plug 'altercation/vim-colors-solarized'
|
||||
|
||||
-- filetype
|
||||
Plug 'towolf/vim-helm'
|
||||
|
||||
vim.call('plug#end')
|
||||
|
||||
|
||||
-- " Plug 'mhinz/neovim-remote'
|
||||
|
||||
-- Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | Plug 'junegunn/fzf.vim'
|
||||
-- Plug 'rking/ag.vim'
|
||||
|
||||
|
||||
|
||||
local cmp = require('cmp')
|
||||
local lspkind = require('lspkind')
|
||||
|
||||
cmp.setup {
|
||||
-- As currently, i am not using any snippet manager, thus disabled it.
|
||||
-- snippet = {
|
||||
-- expand = function(args)
|
||||
-- require("luasnip").lsp_expand(args.body)
|
||||
-- end,
|
||||
-- },
|
||||
|
||||
-- mapping = {
|
||||
-- ["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
-- ["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
-- ["<C-e>"] = cmp.mapping.close(),
|
||||
-- ["<c-y>"] = cmp.mapping.confirm {
|
||||
-- behavior = cmp.ConfirmBehavior.Insert,
|
||||
-- select = true,
|
||||
-- },
|
||||
-- }
|
||||
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<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.
|
||||
}),
|
||||
|
||||
formatting = {
|
||||
format = lspkind.cmp_format {
|
||||
mode = 'symbol_text',
|
||||
menu = {
|
||||
buffer = "[buf]",
|
||||
nvim_lsp = "[LSP]",
|
||||
path = "[path]",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
sources = {
|
||||
{ name = "nvim_lsp"},
|
||||
{ name = "path" },
|
||||
{ name = "buffer" , keyword_length = 2},
|
||||
},
|
||||
|
||||
experimental = {
|
||||
ghost_text = true
|
||||
}
|
||||
}
|
||||
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
-- A list of parser names, or "all" (the four listed parsers should always be installed)
|
||||
ensure_installed = { "lua", "vim", "help" },
|
||||
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
|
||||
-- Automatically install missing parsers when entering buffer
|
||||
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
|
||||
auto_install = false,
|
||||
|
||||
|
||||
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
|
||||
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
|
||||
|
||||
highlight = {
|
||||
-- `false` will disable the whole extension
|
||||
enable = true,
|
||||
|
||||
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
|
||||
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
|
||||
-- the name of the parser)
|
||||
-- list of language that will be disabled
|
||||
-- disable = { "c", "rust" },
|
||||
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
|
||||
disable = function(lang, buf)
|
||||
local max_filesize = 100 * 1024 -- 100 KB
|
||||
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||
if ok and stats and stats.size > max_filesize then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
|
||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||
-- Instead of true it can also be a list of languages
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
}
|
||||
|
||||
require("yanky").setup({
|
||||
ring = {
|
||||
history_length = 100,
|
||||
storage = "shada",
|
||||
sync_with_numbered_registers = true,
|
||||
cancel_event = "update",
|
||||
},
|
||||
system_clipboard = {
|
||||
sync_with_ring = true,
|
||||
},
|
||||
preserve_cursor_position = {
|
||||
enabled = true,
|
||||
},
|
||||
})
|
||||
|
||||
--
|
||||
require("telescope").load_extension("yank_history")
|
||||
Reference in New Issue
Block a user