lua format
This commit is contained in:
parent
4c543d7f44
commit
c3deaa45c6
13
init.lua
13
init.lua
@ -1,16 +1,15 @@
|
||||
local cmd = vim.cmd -- to execute Vim commands e.g. cmd('pwd')
|
||||
local fn = vim.fn -- to call Vim functions e.g. fn.bufnr()
|
||||
local g = vim.g -- a table to access global variables
|
||||
local opt = vim.opt -- to set options
|
||||
local cmd = vim.cmd -- to execute Vim commands e.g. cmd('pwd')
|
||||
local fn = vim.fn -- to call Vim functions e.g. fn.bufnr()
|
||||
local g = vim.g -- a table to access global variables
|
||||
local opt = vim.opt -- to set options
|
||||
local utils = require('utils')
|
||||
|
||||
-------------------- EXTERNAL ------------------------------
|
||||
require('my_plugins')
|
||||
require('my_keymappings')
|
||||
require('my_options')
|
||||
require("my_autocommands")
|
||||
require('my_autocommands')
|
||||
-------------------- TERMINAL ------------------------------
|
||||
require('nvim-terminal').setup({
|
||||
toggle_keymap = '<leader>z',
|
||||
toggle_keymap = '<leader>z',
|
||||
})
|
||||
|
||||
|
@ -3,7 +3,7 @@ function nvim_create_augroups(definitions)
|
||||
vim.cmd('augroup ' .. group_name)
|
||||
vim.cmd('autocmd!')
|
||||
for _, def in ipairs(definition) do
|
||||
local command = table.concat(vim.tbl_flatten{'autocmd', def}, ' ')
|
||||
local command = table.concat(vim.tbl_flatten({ 'autocmd', def }), ' ')
|
||||
vim.cmd(command)
|
||||
end
|
||||
vim.cmd('augroup END')
|
||||
@ -11,35 +11,34 @@ function nvim_create_augroups(definitions)
|
||||
end
|
||||
|
||||
local autocmds = {
|
||||
packer = {
|
||||
{ 'BufWritePost', 'plugins.lua', 'PackerCompile' };
|
||||
};
|
||||
restore_cursor = {
|
||||
{ 'BufRead', '*', [[call setpos(".", getpos("'\""))]] };
|
||||
};
|
||||
save_shada = {
|
||||
{'FocusGained,FocusLost', '*', 'rshada|wshada'};
|
||||
};
|
||||
resize_windows_proportionally = {
|
||||
{ 'VimResized', '*', ':wincmd =' };
|
||||
};
|
||||
lua_highlight = {
|
||||
{ 'TextYankPost', '*', [[silent! lua vim.highlight.on_yank() {higroup='IncSearch', timeout=400}]] };
|
||||
};
|
||||
file_type = {
|
||||
{'BufRead,BufNewFile', '*.simvis', 'set filetype=xml'};
|
||||
{'BufRead,BufNewFile', '*.simcfg,*.simcon,*.simudex', 'set filetype=cfg'};
|
||||
{'BufRead,BufNewFile', 'Jenkinsfile*', 'set filetype=groovy'};
|
||||
{'BufRead,BufNewFile', '*.manifest', 'set filetype=xml'};
|
||||
{'BufRead,BufNewFile', 'SConstruct,SConscript', 'set filetype=python'};
|
||||
};
|
||||
file_changed = {
|
||||
{'BufEnter,FocusGained', '*', 'checktime'};
|
||||
};
|
||||
no_auto_comment = {
|
||||
{'BufEnter', '*', 'set fo-=c fo-=r fo-=o'}
|
||||
}
|
||||
packer = {
|
||||
{ 'BufWritePost', 'plugins.lua', 'PackerCompile' },
|
||||
},
|
||||
restore_cursor = {
|
||||
{ 'BufRead', '*', [[call setpos(".", getpos("'\""))]] },
|
||||
},
|
||||
save_shada = {
|
||||
{ 'FocusGained,FocusLost', '*', 'rshada|wshada' },
|
||||
},
|
||||
resize_windows_proportionally = {
|
||||
{ 'VimResized', '*', ':wincmd =' },
|
||||
},
|
||||
lua_highlight = {
|
||||
{ 'TextYankPost', '*', [[silent! lua vim.highlight.on_yank() {higroup='IncSearch', timeout=400}]] },
|
||||
},
|
||||
file_type = {
|
||||
{ 'BufRead,BufNewFile', '*.simvis', 'set filetype=xml' },
|
||||
{ 'BufRead,BufNewFile', '*.simcfg,*.simcon,*.simudex', 'set filetype=cfg' },
|
||||
{ 'BufRead,BufNewFile', 'Jenkinsfile*', 'set filetype=groovy' },
|
||||
{ 'BufRead,BufNewFile', '*.manifest', 'set filetype=xml' },
|
||||
{ 'BufRead,BufNewFile', 'SConstruct,SConscript', 'set filetype=python' },
|
||||
},
|
||||
file_changed = {
|
||||
{ 'BufEnter,FocusGained', '*', 'checktime' },
|
||||
},
|
||||
no_auto_comment = {
|
||||
{ 'BufEnter', '*', 'set fo-=c fo-=r fo-=o' },
|
||||
},
|
||||
}
|
||||
|
||||
nvim_create_augroups(autocmds)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
local utils = require('utils')
|
||||
vim.g.mapleader = ','
|
||||
utils.map('n', '<space>', 'nil', { noremap = true, silent = true})
|
||||
utils.map('n', '<space>', 'nil', { noremap = true, silent = true })
|
||||
-- Paste from clipboard
|
||||
utils.map('n', '<leader>p', '"+p')
|
||||
utils.map('n', '<leader>P', '"+P')
|
||||
@ -58,18 +58,19 @@ utils.map('v', '>', '>gv')
|
||||
utils.map('n', '<leader>a', '"ayiw')
|
||||
|
||||
-- Highlight word under cursor
|
||||
utils.map('n', 'ü', ":let @/='\\<<C-R>=expand(\"<cword>\")<CR>\\>'<CR>:set hls<CR>", { noremap = true, silent = true })
|
||||
utils.map('v', 'ü', "y:let @/='<C-R>=escape(@\",'/\\')<CR>'<CR>:set hls<CR>") utils.map('v', 'ü', "y:let @/='<C-R>=escape(@\",'/\\')<CR>'<CR>:set hls<CR>", { noremap = true, silent = true })
|
||||
utils.map('n', 'ü', ':let @/=\'\\<<C-R>=expand("<cword>")<CR>\\>\'<CR>:set hls<CR>', { noremap = true, silent = true })
|
||||
utils.map('v', 'ü', "y:let @/='<C-R>=escape(@\",'/\\')<CR>'<CR>:set hls<CR>")
|
||||
utils.map('v', 'ü', "y:let @/='<C-R>=escape(@\",'/\\')<CR>'<CR>:set hls<CR>", { noremap = true, silent = true })
|
||||
|
||||
-- Close Buffer
|
||||
utils.map('n', '<C-w>', ':bd<CR>')
|
||||
|
||||
-- <Tab> to navigate the completion menu
|
||||
utils.map('i', '<S-Tab>', 'pumvisible() ? "\\<C-p>" : "\\<Tab>"', {expr = true})
|
||||
utils.map('i', '<Tab>', 'pumvisible() ? "\\<C-n>" : "\\<Tab>"', {expr = true})
|
||||
utils.map('i', '<S-Tab>', 'pumvisible() ? "\\<C-p>" : "\\<Tab>"', { expr = true })
|
||||
utils.map('i', '<Tab>', 'pumvisible() ? "\\<C-n>" : "\\<Tab>"', { expr = true })
|
||||
|
||||
-- Telescope
|
||||
utils.map('n', '<leader>f', '<cmd>lua require(\'telescope.builtin\').find_files({no_ignore=true})<cr>')
|
||||
utils.map('n', '<leader>f', "<cmd>lua require('telescope.builtin').find_files({no_ignore=true})<cr>")
|
||||
utils.map('n', '<C-p>', '<cmd>lua require("telescope.builtin").find_files({no_ignore=true})<cr>')
|
||||
utils.map('n', '<leader>g', '<cmd>Telescope git_files<cr>')
|
||||
utils.map('n', '<leader>o', '<cmd>Telescope oldfiles<cr>')
|
||||
|
@ -1,13 +1,13 @@
|
||||
local utils = require('utils')
|
||||
vim.g.gruvbox_material_diagnostic_text_highlight=1
|
||||
vim.g.gruvbox_material_diagnostic_virtual_text='colored'
|
||||
vim.g.gruvbox_bold=0
|
||||
vim.g.gruvbox_italicize_comments=0
|
||||
vim.g.gruvbox_italicize_strings=0
|
||||
vim.cmd 'colorscheme gruvbox' -- Put your favorite colorscheme here
|
||||
vim.cmd 'syntax enable'
|
||||
vim.cmd 'filetype plugin indent on'
|
||||
vim.cmd 'language en_US.utf-8'
|
||||
vim.g.gruvbox_material_diagnostic_text_highlight = 1
|
||||
vim.g.gruvbox_material_diagnostic_virtual_text = 'colored'
|
||||
vim.g.gruvbox_bold = 0
|
||||
vim.g.gruvbox_italicize_comments = 0
|
||||
vim.g.gruvbox_italicize_strings = 0
|
||||
vim.cmd('colorscheme gruvbox') -- Put your favorite colorscheme here
|
||||
vim.cmd('syntax enable')
|
||||
vim.cmd('filetype plugin indent on')
|
||||
vim.cmd('language en_US.utf-8')
|
||||
utils.opt('o', 'hlsearch', true)
|
||||
utils.opt('o', 'guifont', 'JetBrainsMono Nerd Font:h9')
|
||||
utils.opt('o', 'swapfile', false)
|
||||
@ -21,7 +21,7 @@ utils.opt('b', 'smartindent', true)
|
||||
utils.opt('b', 'tabstop', indent)
|
||||
utils.opt('o', 'hidden', true)
|
||||
utils.opt('o', 'ignorecase', true)
|
||||
utils.opt('o', 'scrolloff', 4 )
|
||||
utils.opt('o', 'scrolloff', 4)
|
||||
utils.opt('o', 'shiftround', true)
|
||||
utils.opt('o', 'relativenumber', false)
|
||||
utils.opt('o', 'smartcase', true)
|
||||
|
@ -6,64 +6,71 @@ vim.cmd([[
|
||||
]])
|
||||
|
||||
local fn = vim.fn
|
||||
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
|
||||
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
|
||||
if fn.empty(fn.glob(install_path)) > 0 then
|
||||
packer_bootstrap = fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--depth",
|
||||
"1",
|
||||
"https://github.com/wbthomason/packer.nvim",
|
||||
'git',
|
||||
'clone',
|
||||
'--depth',
|
||||
'1',
|
||||
'https://github.com/wbthomason/packer.nvim',
|
||||
install_path,
|
||||
})
|
||||
end
|
||||
vim.api.nvim_command("packadd packer.nvim")
|
||||
vim.api.nvim_command('packadd packer.nvim')
|
||||
|
||||
function get_setup(name)
|
||||
return string.format('require("setup/%s")', name)
|
||||
end
|
||||
|
||||
return require('packer').startup(function()
|
||||
local packerUtil = require('packer.util')
|
||||
require('packer').init({
|
||||
snapshot_path = packerUtil.join_paths(vim.fn.stdpath('config'), 'snapshots'),
|
||||
display = {
|
||||
open_fn = require('packer.util').float,
|
||||
},
|
||||
})
|
||||
|
||||
return require('packer').startup(function()
|
||||
-- Packer can manage itself as an optional plugin
|
||||
use {'wbthomason/packer.nvim'}
|
||||
use {'neovim/nvim-lspconfig'}
|
||||
use {
|
||||
use({ 'wbthomason/packer.nvim' })
|
||||
use({ 'neovim/nvim-lspconfig' })
|
||||
use({
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
run = ':TSUpdate',
|
||||
config = get_setup("treesitter")
|
||||
}
|
||||
config = get_setup('treesitter'),
|
||||
})
|
||||
use({
|
||||
'nvim-telescope/telescope.nvim',
|
||||
requires = {
|
||||
{'nvim-lua/popup.nvim'},
|
||||
{'nvim-lua/plenary.nvim'},
|
||||
{'kyazdani42/nvim-web-devicons'},
|
||||
{'nvim-telescope/telescope-fzf-native.nvim', run = 'make'}
|
||||
{ 'nvim-lua/popup.nvim' },
|
||||
{ 'nvim-lua/plenary.nvim' },
|
||||
{ 'kyazdani42/nvim-web-devicons' },
|
||||
{ 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' },
|
||||
},
|
||||
config = get_setup("telescope"),
|
||||
config = get_setup('telescope'),
|
||||
})
|
||||
use {'sainnhe/gruvbox-material'}
|
||||
use {'ellisonleao/gruvbox.nvim'}
|
||||
use {
|
||||
use({ 'sainnhe/gruvbox-material' })
|
||||
use({ 'ellisonleao/gruvbox.nvim' })
|
||||
use({
|
||||
'lukas-reineke/indent-blankline.nvim',
|
||||
config = get_setup("indent_blankline")
|
||||
}
|
||||
use {'nvim-lua/plenary.nvim'}
|
||||
use {
|
||||
config = get_setup('indent_blankline'),
|
||||
})
|
||||
use({ 'nvim-lua/plenary.nvim' })
|
||||
use({
|
||||
'lewis6991/gitsigns.nvim',
|
||||
config = get_setup("gitsigns")
|
||||
}
|
||||
use {
|
||||
'kyazdani42/nvim-tree.lua',
|
||||
requires = 'kyazdani42/nvim-web-devicons',
|
||||
config = get_setup("nvim-tree")
|
||||
}
|
||||
use{
|
||||
config = get_setup('gitsigns'),
|
||||
})
|
||||
use({
|
||||
'kyazdani42/nvim-tree.lua',
|
||||
requires = 'kyazdani42/nvim-web-devicons',
|
||||
config = get_setup('nvim-tree'),
|
||||
})
|
||||
use({
|
||||
'numToStr/Comment.nvim',
|
||||
config = get_setup("comment")
|
||||
}
|
||||
use {
|
||||
config = get_setup('comment'),
|
||||
})
|
||||
use({
|
||||
'hrsh7th/nvim-cmp',
|
||||
requires = {
|
||||
'hrsh7th/cmp-buffer',
|
||||
@ -76,62 +83,58 @@ return require('packer').startup(function()
|
||||
'hrsh7th/cmp-calc',
|
||||
'f3fora/cmp-spell',
|
||||
'hrsh7th/cmp-emoji',
|
||||
'hrsh7th/cmp-cmdline'
|
||||
'hrsh7th/cmp-cmdline',
|
||||
},
|
||||
config = get_setup("cmp")
|
||||
}
|
||||
use {'L3MON4D3/LuaSnip',
|
||||
config = get_setup("luasnip")
|
||||
}
|
||||
use {'rafamadriz/friendly-snippets'}
|
||||
use {'onsails/lspkind-nvim'}
|
||||
use {'Shatur/neovim-cmake',
|
||||
requires = {'mfussenegger/nvim-dap'},
|
||||
config = get_setup("cmake")
|
||||
}
|
||||
use {
|
||||
config = get_setup('cmp'),
|
||||
})
|
||||
use({ 'L3MON4D3/LuaSnip', config = get_setup('luasnip') })
|
||||
use({ 'rafamadriz/friendly-snippets' })
|
||||
use({ 'onsails/lspkind-nvim' })
|
||||
use({ 'Shatur/neovim-cmake', requires = { 'mfussenegger/nvim-dap' }, config = get_setup('cmake') })
|
||||
use({
|
||||
'hoob3rt/lualine.nvim',
|
||||
requires = {'kyazdani42/nvim-web-devicons', opt = true},
|
||||
config = get_setup("lualine")
|
||||
}
|
||||
use {
|
||||
requires = { 'kyazdani42/nvim-web-devicons', opt = true },
|
||||
config = get_setup('lualine'),
|
||||
})
|
||||
use({
|
||||
'ahmedkhalf/project.nvim',
|
||||
config = get_setup("project")
|
||||
}
|
||||
use {'p00f/nvim-ts-rainbow'}
|
||||
use {
|
||||
config = get_setup('project'),
|
||||
})
|
||||
use({ 'p00f/nvim-ts-rainbow' })
|
||||
use({
|
||||
'windwp/nvim-autopairs',
|
||||
config = get_setup("nvim-autopairs")
|
||||
}
|
||||
use {'ray-x/lsp_signature.nvim'}
|
||||
use {'s1n7ax/nvim-terminal'}
|
||||
use {
|
||||
config = get_setup('nvim-autopairs'),
|
||||
})
|
||||
use({ 'ray-x/lsp_signature.nvim' })
|
||||
use({ 's1n7ax/nvim-terminal' })
|
||||
use({
|
||||
'williamboman/nvim-lsp-installer',
|
||||
requires = {'neovim/nvim-lspconfig'},
|
||||
config = get_setup("lspinstall")
|
||||
}
|
||||
use {
|
||||
requires = { 'neovim/nvim-lspconfig' },
|
||||
config = get_setup('lspinstall'),
|
||||
})
|
||||
use({
|
||||
'jose-elias-alvarez/null-ls.nvim',
|
||||
requires = {'nvim-lua/plenary.nvim'}
|
||||
}
|
||||
use {
|
||||
requires = { 'nvim-lua/plenary.nvim' },
|
||||
})
|
||||
use({
|
||||
'danymat/neogen',
|
||||
requires = 'nvim-treesitter/nvim-treesitter',
|
||||
config = get_setup("neogen")
|
||||
}
|
||||
use {'abecodes/tabout.nvim'}
|
||||
use {'stevearc/dressing.nvim'}
|
||||
use {
|
||||
config = get_setup('neogen'),
|
||||
})
|
||||
use({ 'abecodes/tabout.nvim' })
|
||||
use({ 'stevearc/dressing.nvim' })
|
||||
use({
|
||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||
requires = "nvim-treesitter/nvim-treesitter"
|
||||
}
|
||||
use {'mvllow/modes.nvim',
|
||||
requires = 'nvim-treesitter/nvim-treesitter',
|
||||
})
|
||||
use({
|
||||
'mvllow/modes.nvim',
|
||||
config = function()
|
||||
vim.opt.cursorline = true
|
||||
require('modes').setup({
|
||||
focus_only = true,
|
||||
line_opacity = 0.2,
|
||||
})
|
||||
end
|
||||
}
|
||||
end,
|
||||
})
|
||||
end)
|
||||
|
@ -1,4 +1,4 @@
|
||||
local opt = vim.opt -- to set options
|
||||
local opt = vim.opt -- to set options
|
||||
local utils = require('utils')
|
||||
-- require('telescope').load_extension('cmake')
|
||||
require('cmake').setup({
|
||||
@ -8,7 +8,6 @@ require('cmake').setup({
|
||||
utils.map('n', '<F5>', ':CMake build<CR>:copen<CR>')
|
||||
|
||||
-- msbuild errorformat
|
||||
opt.errorformat:append("\\ %#%f(%l\\\\\\,%c):\\ %m")
|
||||
opt.errorformat:append('\\ %#%f(%l\\\\\\,%c):\\ %m')
|
||||
-- cl.exe errorformat
|
||||
-- o.errorformat:append('\ %#%f(%l) : %#%t%[A-z]%# %m')
|
||||
|
||||
|
@ -1,101 +1,106 @@
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require("luasnip")
|
||||
local luasnip = require('luasnip')
|
||||
|
||||
local t = function(str)
|
||||
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||
end
|
||||
|
||||
local check_back_space = function()
|
||||
local col = vim.fn.col(".") - 1
|
||||
return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") ~= nil
|
||||
local col = vim.fn.col('.') - 1
|
||||
return col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') ~= nil
|
||||
end
|
||||
|
||||
cmp.setup {
|
||||
cmp.setup({
|
||||
|
||||
formatting = {
|
||||
format = function(entry, vim_item)
|
||||
-- fancy icons and a name of kind
|
||||
vim_item.kind = require("lspkind").presets.default[vim_item.kind] ..
|
||||
" " .. vim_item.kind
|
||||
-- set a name for each source
|
||||
vim_item.menu = ({
|
||||
buffer = "[Buffer]",
|
||||
nvim_lsp = "[LSP]",
|
||||
ultisnips = "[UltiSnips]",
|
||||
nvim_lua = "[Lua]",
|
||||
cmp_tabnine = "[TabNine]",
|
||||
look = "[Look]",
|
||||
path = "[Path]",
|
||||
spell = "[Spell]",
|
||||
calc = "[Calc]",
|
||||
emoji = "[Emoji]"
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end
|
||||
},
|
||||
mapping = {
|
||||
['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c', 's'}),
|
||||
['<Down>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c', 's' }),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }),
|
||||
['<C-e>'] = cmp.mapping(cmp.mapping.close(), { 'i', 'c', 's' }),
|
||||
['<CR>'] = cmp.mapping({
|
||||
i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }),
|
||||
c = cmp.mapping.confirm({ select = false }),
|
||||
s = cmp.mapping.confirm({ select = false }),
|
||||
}),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if luasnip.expand_or_jumpable() then
|
||||
vim.api.nvim_feedkeys(t("<Plug>luasnip-expand-or-jump"), "", true)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {
|
||||
"i",
|
||||
"s",
|
||||
}),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if luasnip.jumpable(-1) then
|
||||
vim.api.nvim_feedkeys(t("<Plug>luasnip-jump-prev"), "", true)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {
|
||||
"i",
|
||||
"s",
|
||||
}),
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require'luasnip'.lsp_expand(args.body)
|
||||
formatting = {
|
||||
format = function(entry, vim_item)
|
||||
-- fancy icons and a name of kind
|
||||
vim_item.kind = require('lspkind').presets.default[vim_item.kind] .. ' ' .. vim_item.kind
|
||||
-- set a name for each source
|
||||
vim_item.menu = ({
|
||||
buffer = '[Buffer]',
|
||||
nvim_lsp = '[LSP]',
|
||||
ultisnips = '[UltiSnips]',
|
||||
nvim_lua = '[Lua]',
|
||||
cmp_tabnine = '[TabNine]',
|
||||
look = '[Look]',
|
||||
path = '[Path]',
|
||||
spell = '[Spell]',
|
||||
calc = '[Calc]',
|
||||
emoji = '[Emoji]',
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c', 's' }),
|
||||
['<Down>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c', 's' }),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }),
|
||||
['<C-e>'] = cmp.mapping(cmp.mapping.close(), { 'i', 'c', 's' }),
|
||||
['<CR>'] = cmp.mapping({
|
||||
i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }),
|
||||
c = cmp.mapping.confirm({ select = false }),
|
||||
s = cmp.mapping.confirm({ select = false }),
|
||||
}),
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if luasnip.expand_or_jumpable() then
|
||||
vim.api.nvim_feedkeys(t('<Plug>luasnip-expand-or-jump'), '', true)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
},
|
||||
sources = {
|
||||
{name = "luasnip"}, {name = 'nvim_lsp'}, {name = 'buffer'},
|
||||
{name = "nvim_lua"}, {name = "look"}, {name = "path"},
|
||||
{name = 'cmp_tabnine'}, {name = "calc"}, {name = "spell"},
|
||||
{name = "emoji"}
|
||||
},
|
||||
completion = {completeopt = 'menu,menuone,noinsert, noselect'},
|
||||
-- experimental = { native_menu = true }
|
||||
}
|
||||
end, {
|
||||
'i',
|
||||
's',
|
||||
}),
|
||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if luasnip.jumpable(-1) then
|
||||
vim.api.nvim_feedkeys(t('<Plug>luasnip-jump-prev'), '', true)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {
|
||||
'i',
|
||||
's',
|
||||
}),
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
sources = {
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'buffer' },
|
||||
{ name = 'nvim_lua' },
|
||||
{ name = 'look' },
|
||||
{ name = 'path' },
|
||||
{ name = 'cmp_tabnine' },
|
||||
{ name = 'calc' },
|
||||
{ name = 'spell' },
|
||||
{ name = 'emoji' },
|
||||
},
|
||||
completion = { completeopt = 'menu,menuone,noinsert, noselect' },
|
||||
-- experimental = { native_menu = true }
|
||||
})
|
||||
|
||||
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline('/', {
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
{ name = 'buffer' },
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
{ name = 'path' },
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
{ name = 'cmdline' },
|
||||
}, {
|
||||
{ name = 'buffer' }
|
||||
{ name = 'buffer' },
|
||||
}),
|
||||
})
|
||||
|
||||
@ -106,13 +111,16 @@ cmp.setup.cmdline(':', {
|
||||
-- auto_select = true
|
||||
--})
|
||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||
cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } }))
|
||||
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } }))
|
||||
|
||||
-- TabNine
|
||||
--local tabnine = require('cmp_tabnine.config')
|
||||
--tabnine:setup({max_lines = 1000, max_num_results = 20, sort = true})
|
||||
|
||||
-- Database completion
|
||||
vim.api.nvim_exec([[
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
autocmd FileType sql,mysql,plsql lua require('cmp').setup.buffer({ sources = {{ name = 'vim-dadbod-completion' }} })
|
||||
]], false)
|
||||
]],
|
||||
false
|
||||
)
|
||||
|
@ -1,12 +1,12 @@
|
||||
local opt = vim.opt -- to set options
|
||||
opt.listchars:append("eol:↴")
|
||||
local opt = vim.opt -- to set options
|
||||
opt.listchars:append('eol:↴')
|
||||
-- opt.listchars:append("space: ")
|
||||
opt.listchars:append("trail: ")
|
||||
opt.listchars:append("tab:→ ")
|
||||
opt.listchars:append('trail: ')
|
||||
opt.listchars:append('tab:→ ')
|
||||
|
||||
require("indent_blankline").setup {
|
||||
require('indent_blankline').setup({
|
||||
show_end_of_line = true,
|
||||
use_treesitter = true,
|
||||
show_current_context = true,
|
||||
context_patterns = {'class', 'function', 'method', 'block', '^if', '^for', '^while'},
|
||||
}
|
||||
context_patterns = { 'class', 'function', 'method', 'block', '^if', '^for', '^while' },
|
||||
})
|
||||
|
@ -9,7 +9,7 @@ capabilities.textDocument.completion.completionItem.labelDetailsSupport = true
|
||||
capabilities.textDocument.completion.completionItem.deprecatedSupport = true
|
||||
capabilities.textDocument.completion.completionItem.commitCharactersSupport = true
|
||||
capabilities.textDocument.completion.completionItem.tagSupport = { valueSet = { 1 } }
|
||||
capabilities.offsetEncoding = { "utf-16" }
|
||||
capabilities.offsetEncoding = { 'utf-16' }
|
||||
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||||
properties = {
|
||||
'documentation',
|
||||
@ -19,14 +19,18 @@ capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
vim.api.nvim_buf_set_option(0, 'formatexpr', 'v:lua.vim.lsp.formatexpr()')
|
||||
|
||||
-- Mappings.
|
||||
local opts = { noremap=true, silent=true }
|
||||
local opts = { noremap = true, silent = true }
|
||||
buf_set_keymap('n', '<space>,', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>;', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>a', '<cmd>Telescope lsp_code_actions<CR>', opts)
|
||||
@ -47,7 +51,7 @@ local on_attach = function(client, bufnr)
|
||||
buf_set_keymap('n', '<space>v', '<cmd>Telescope diagnostics bufnr=0<cr>', opts)
|
||||
buf_set_keymap('n', '<A-o>', ':ClangdSwitchSourceHeader<CR>', opts)
|
||||
|
||||
vim.cmd [[autocmd CursorHold <buffer> lua vim.diagnostic.open_float({focusable = false})]]
|
||||
vim.cmd([[autocmd CursorHold <buffer> lua vim.diagnostic.open_float({focusable = false})]])
|
||||
|
||||
-- Set some keybinds conditional on server capabilities
|
||||
if client.resolved_capabilities.document_formatting then
|
||||
@ -59,7 +63,8 @@ local on_attach = function(client, bufnr)
|
||||
|
||||
-- Set autocommands conditional on server_capabilities
|
||||
if client.resolved_capabilities.document_highlight then
|
||||
vim.api.nvim_exec([[
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
hi LspReferenceRead cterm=bold ctermbg=red guibg=DarkGreen
|
||||
hi LspReferenceWrite cterm=bold ctermbg=red guibg=DarkRed
|
||||
augroup lsp_document_highlight
|
||||
@ -68,34 +73,36 @@ local on_attach = function(client, bufnr)
|
||||
autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight()
|
||||
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
||||
augroup END
|
||||
]], false)
|
||||
]],
|
||||
false
|
||||
)
|
||||
end
|
||||
require "lsp_signature".on_attach({
|
||||
bind = true, -- This is mandatory, otherwise border config won't get registered.
|
||||
handler_opts = {
|
||||
border = "single"
|
||||
},
|
||||
hi_parameter = "IncSearch"
|
||||
}, bufnr)
|
||||
require('lsp_signature').on_attach({
|
||||
bind = true, -- This is mandatory, otherwise border config won't get registered.
|
||||
handler_opts = {
|
||||
border = 'single',
|
||||
},
|
||||
hi_parameter = 'IncSearch',
|
||||
}, bufnr)
|
||||
end
|
||||
|
||||
local lsp_installer = require("nvim-lsp-installer")
|
||||
local lsp_installer = require('nvim-lsp-installer')
|
||||
|
||||
local servers = {
|
||||
"pyright",
|
||||
"cmake",
|
||||
"clangd",
|
||||
"jsonls",
|
||||
"groovyls",
|
||||
"sumneko_lua",
|
||||
"dockerls",
|
||||
'pyright',
|
||||
'cmake',
|
||||
'clangd',
|
||||
'jsonls',
|
||||
'groovyls',
|
||||
'sumneko_lua',
|
||||
'dockerls',
|
||||
}
|
||||
|
||||
for _, name in pairs(servers) do
|
||||
local server_is_found, server = lsp_installer.get_server(name)
|
||||
if server_is_found then
|
||||
if not server:is_installed() then
|
||||
print("Installing " .. name)
|
||||
print('Installing ' .. name)
|
||||
server:install()
|
||||
end
|
||||
end
|
||||
@ -107,18 +114,18 @@ lsp_installer.on_server_ready(function(server)
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
-- (optional) Customize the options passed to the server
|
||||
if server.name == "clangd" then
|
||||
opts.cmd = { "clangd" , "--compile-commands-dir=build_nvim"}
|
||||
end
|
||||
-- (optional) Customize the options passed to the server
|
||||
if server.name == 'clangd' then
|
||||
opts.cmd = { 'clangd', '--compile-commands-dir=build_nvim' }
|
||||
end
|
||||
|
||||
-- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart)
|
||||
server:setup(opts)
|
||||
vim.cmd [[ do User LspAttachBuffers ]]
|
||||
-- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart)
|
||||
server:setup(opts)
|
||||
vim.cmd([[ do User LspAttachBuffers ]])
|
||||
end)
|
||||
|
||||
local null_ls = require("null-ls")
|
||||
null_ls.setup {
|
||||
local null_ls = require('null-ls')
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
null_ls.builtins.code_actions.gitsigns,
|
||||
null_ls.builtins.formatting.autopep8,
|
||||
@ -126,9 +133,9 @@ null_ls.setup {
|
||||
null_ls.builtins.formatting.stylua,
|
||||
null_ls.builtins.diagnostics.flake8,
|
||||
null_ls.builtins.formatting.isort,
|
||||
null_ls.builtins.formatting.cmake_format
|
||||
null_ls.builtins.formatting.cmake_format,
|
||||
},
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities
|
||||
}
|
||||
vim.diagnostic.config({virtual_text = false})
|
||||
capabilities = capabilities,
|
||||
})
|
||||
vim.diagnostic.config({ virtual_text = false })
|
||||
|
@ -1,5 +1,5 @@
|
||||
require('lualine').setup {
|
||||
options = {theme = 'gruvbox-material'},
|
||||
sections = {lualine_c = {'getcwd', {'filename', path = 1, file_status = true}}},
|
||||
inactive_sections = {lualine_c = {'getcwd', {'filename', path = 1, file_status = true}}}
|
||||
}
|
||||
require('lualine').setup({
|
||||
options = { theme = 'gruvbox-material' },
|
||||
sections = { lualine_c = { 'getcwd', { 'filename', path = 1, file_status = true } } },
|
||||
inactive_sections = { lualine_c = { 'getcwd', { 'filename', path = 1, file_status = true } } },
|
||||
})
|
||||
|
@ -1,5 +1,5 @@
|
||||
local ls = require("luasnip")
|
||||
require("luasnip.loaders.from_vscode").load()
|
||||
local ls = require('luasnip')
|
||||
require('luasnip.loaders.from_vscode').load()
|
||||
-- some shorthands...
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
@ -10,25 +10,24 @@ local f = ls.function_node
|
||||
local c = ls.choice_node
|
||||
local d = ls.dynamic_node
|
||||
local r = ls.restore_node
|
||||
local l = require("luasnip.extras").lambda
|
||||
local rep = require("luasnip.extras").rep
|
||||
local p = require("luasnip.extras").partial
|
||||
local m = require("luasnip.extras").match
|
||||
local n = require("luasnip.extras").nonempty
|
||||
local dl = require("luasnip.extras").dynamic_lambda
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local types = require("luasnip.util.types")
|
||||
local conds = require("luasnip.extras.expand_conditions")
|
||||
local l = require('luasnip.extras').lambda
|
||||
local rep = require('luasnip.extras').rep
|
||||
local p = require('luasnip.extras').partial
|
||||
local m = require('luasnip.extras').match
|
||||
local n = require('luasnip.extras').nonempty
|
||||
local dl = require('luasnip.extras').dynamic_lambda
|
||||
local fmt = require('luasnip.extras.fmt').fmt
|
||||
local fmta = require('luasnip.extras.fmt').fmta
|
||||
local types = require('luasnip.util.types')
|
||||
local conds = require('luasnip.extras.expand_conditions')
|
||||
|
||||
local function getRegA(capitalize)
|
||||
local clipboard = vim.fn.getreg('a')
|
||||
clipboard = clipboard:gsub('^m_', '')
|
||||
if capitalize then
|
||||
clipboard = clipboard:gsub("^%l", string.upper);
|
||||
clipboard = clipboard:gsub('^%l', string.upper)
|
||||
end
|
||||
return clipboard
|
||||
|
||||
return clipboard
|
||||
end
|
||||
|
||||
|
||||
|
@ -1,20 +1,20 @@
|
||||
require('neogen').setup {
|
||||
require('neogen').setup({
|
||||
enabled = true,
|
||||
languages = {
|
||||
cpp = {
|
||||
template = {
|
||||
annotation_convention = "custom",
|
||||
custom = {
|
||||
{ nil, "/// file", { no_results = true, type = { "file" } } },
|
||||
{ nil, "/// $1", { no_results = true, type = { "func", "file" } } },
|
||||
{ nil, "", { no_results = true, type = { "file" } } },
|
||||
annotation_convention = 'custom',
|
||||
custom = {
|
||||
{ nil, '/// file', { no_results = true, type = { 'file' } } },
|
||||
{ nil, '/// $1', { no_results = true, type = { 'func', 'file' } } },
|
||||
{ nil, '', { no_results = true, type = { 'file' } } },
|
||||
|
||||
{ nil, "/// $1", { type = { "func" } } },
|
||||
{ "tparam", "/// \\tparam %s $1" },
|
||||
{ "parameters", "/// \\param %s $1" },
|
||||
{ "return_statement", "/// \\return $1" },
|
||||
{ nil, '/// $1', { type = { 'func' } } },
|
||||
{ 'tparam', '/// \\tparam %s $1' },
|
||||
{ 'parameters', '/// \\param %s $1' },
|
||||
{ 'return_statement', '/// \\return $1' },
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
@ -1 +1 @@
|
||||
require('nvim-autopairs').setup{}
|
||||
require('nvim-autopairs').setup({})
|
||||
|
@ -1,26 +1,26 @@
|
||||
local utils = require('utils')
|
||||
require('nvim-tree').setup({
|
||||
auto_close = true,
|
||||
update_cwd = true,
|
||||
update_to_buf_dir = {
|
||||
update_cwd = true,
|
||||
update_to_buf_dir = {
|
||||
-- enable the feature
|
||||
enable = true,
|
||||
-- allow to open the tree if it was previously closed
|
||||
auto_open = false,
|
||||
},
|
||||
update_focused_file = {
|
||||
enable = true,
|
||||
update_cwd = false,
|
||||
ignore_list = {}
|
||||
enable = true,
|
||||
update_cwd = false,
|
||||
ignore_list = {},
|
||||
},
|
||||
diagnostics = {
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
icons = {
|
||||
hint = "",
|
||||
info = "",
|
||||
warning = "",
|
||||
error = "",
|
||||
}
|
||||
hint = '',
|
||||
info = '',
|
||||
warning = '',
|
||||
error = '',
|
||||
},
|
||||
},
|
||||
})
|
||||
utils.map('n', '<leader>tt', '<cmd>NvimTreeToggle<CR>')
|
||||
|
@ -1,6 +1,6 @@
|
||||
local utils = require('utils')
|
||||
require("project_nvim").setup {
|
||||
require('project_nvim').setup({
|
||||
silent_chdir = true,
|
||||
}
|
||||
})
|
||||
require('telescope').load_extension('projects')
|
||||
utils.map('n', '<space>p', '<cmd>Telescope projects<cr>')
|
||||
|
@ -4,19 +4,19 @@ local mappingTab = {
|
||||
i = {
|
||||
['<cr>'] = actions.select_tab,
|
||||
['<C-b>'] = actions.select_default,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
require('telescope').setup {
|
||||
require('telescope').setup({
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
['<esc>'] = actions.close,
|
||||
['<cr>'] = actions.select_default + actions.center,
|
||||
['<C-l>'] = actions.send_selected_to_loclist,
|
||||
['<C-q>'] = actions.smart_send_to_qflist
|
||||
}
|
||||
}
|
||||
['<C-q>'] = actions.smart_send_to_qflist,
|
||||
},
|
||||
},
|
||||
},
|
||||
pickers = {
|
||||
-- Your special builtin config goes in here
|
||||
@ -30,8 +30,8 @@ require('telescope').setup {
|
||||
},
|
||||
n = {
|
||||
['<c-w>'] = actions.delete_buffer,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
find_files = {
|
||||
theme = 'ivy',
|
||||
@ -44,9 +44,8 @@ require('telescope').setup {
|
||||
theme = 'ivy',
|
||||
previewer = false,
|
||||
},
|
||||
lsp_dynamic_workspace_symbols = {
|
||||
},
|
||||
}
|
||||
}
|
||||
lsp_dynamic_workspace_symbols = {},
|
||||
},
|
||||
})
|
||||
|
||||
require('telescope').load_extension('fzf')
|
||||
|
@ -1,15 +1,19 @@
|
||||
local utils = { }
|
||||
local utils = {}
|
||||
|
||||
local scopes = {o = vim.o, b = vim.bo, w = vim.wo}
|
||||
local scopes = { o = vim.o, b = vim.bo, w = vim.wo }
|
||||
|
||||
function utils.opt(scope, key, value)
|
||||
scopes[scope][key] = value
|
||||
if scope ~= 'o' then scopes['o'][key] = value end
|
||||
scopes[scope][key] = value
|
||||
if scope ~= 'o' then
|
||||
scopes['o'][key] = value
|
||||
end
|
||||
end
|
||||
|
||||
function utils.map(mode, lhs, rhs, opts)
|
||||
local options = {noremap = true}
|
||||
if opts then options = vim.tbl_extend('force', options, opts) end
|
||||
local options = { noremap = true }
|
||||
if opts then
|
||||
options = vim.tbl_extend('force', options, opts)
|
||||
end
|
||||
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user