more restructure
This commit is contained in:
parent
fd16ef223a
commit
ce61facff9
@ -48,6 +48,7 @@ opt.expandtab= true
|
|||||||
opt.smartindent= true
|
opt.smartindent= true
|
||||||
opt.title = true
|
opt.title = true
|
||||||
opt.titlestring = '%{getcwd()} - %t'
|
opt.titlestring = '%{getcwd()} - %t'
|
||||||
|
opt.laststatus = 3 -- for lualine
|
||||||
|
|
||||||
-- go to previous/next line with h,l,left arrow and right arrow
|
-- go to previous/next line with h,l,left arrow and right arrow
|
||||||
-- when cursor reaches end/beginning of line
|
-- when cursor reaches end/beginning of line
|
||||||
|
180
lua/plugins/cmp.lua
Normal file
180
lua/plugins/cmp.lua
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
return {
|
||||||
|
'hrsh7th/nvim-cmp',
|
||||||
|
dependencies = {
|
||||||
|
{ 'onsails/lspkind-nvim' },
|
||||||
|
{ 'hrsh7th/cmp-buffer' },
|
||||||
|
{ 'hrsh7th/cmp-nvim-lsp' },
|
||||||
|
{
|
||||||
|
'L3MON4D3/LuaSnip',
|
||||||
|
config = function()
|
||||||
|
require('setup/luasnip')
|
||||||
|
end,
|
||||||
|
dependencies =
|
||||||
|
{
|
||||||
|
'rafamadriz/friendly-snippets'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ 'saadparwaiz1/cmp_luasnip' },
|
||||||
|
{ 'hrsh7th/cmp-nvim-lua' },
|
||||||
|
{ 'octaltree/cmp-look' },
|
||||||
|
{ 'hrsh7th/cmp-path' },
|
||||||
|
{ 'hrsh7th/cmp-calc' },
|
||||||
|
{ 'f3fora/cmp-spell' },
|
||||||
|
{ 'hrsh7th/cmp-emoji' },
|
||||||
|
{ 'hrsh7th/cmp-cmdline' },
|
||||||
|
{ 'dmitmel/cmp-cmdline-history' },
|
||||||
|
{ 'ray-x/cmp-treesitter' },
|
||||||
|
{ 'hrsh7th/cmp-nvim-lsp-signature-help' },
|
||||||
|
{ 'p00f/clangd_extensions.nvim' },
|
||||||
|
{
|
||||||
|
'windwp/nvim-autopairs',
|
||||||
|
config = function()
|
||||||
|
require('setup/nvim-autopairs')
|
||||||
|
end
|
||||||
|
},
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local cmp = require('cmp')
|
||||||
|
local luasnip = require('luasnip')
|
||||||
|
|
||||||
|
local t = function(str)
|
||||||
|
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
|
||||||
|
end
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
formatting = {
|
||||||
|
format = require('lspkind').cmp_format({
|
||||||
|
mode = 'symbol_text', -- show only symbol annotations
|
||||||
|
maxwidth = 80, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
|
||||||
|
ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
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 = false }),
|
||||||
|
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)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
{ name = 'luasnip', priority = 8 },
|
||||||
|
{ name = 'nvim_lsp', priority = 7 },
|
||||||
|
{ name = 'nvim_lsp_signature_help', priority = 7 },
|
||||||
|
{ name = 'treesitter', priority = 6 },
|
||||||
|
{ name = 'buffer', priority = 5,
|
||||||
|
option = {
|
||||||
|
get_bufnrs = function()
|
||||||
|
local bufs = {}
|
||||||
|
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
||||||
|
bufs[vim.api.nvim_win_get_buf(win)] = true
|
||||||
|
end
|
||||||
|
return vim.tbl_keys(bufs)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
},
|
||||||
|
-- { name = 'nvim_lua' },
|
||||||
|
-- { name = 'look' },
|
||||||
|
-- { name = 'path' },
|
||||||
|
-- { name = 'cmp_tabnine' },
|
||||||
|
-- { name = 'calc' },
|
||||||
|
-- { name = 'spell' },
|
||||||
|
-- { name = 'emoji' },
|
||||||
|
},
|
||||||
|
enabled = function()
|
||||||
|
return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt"
|
||||||
|
or vim.api.nvim_buf_get_option(0, 'filetype') == 'dap-repl'
|
||||||
|
or vim.api.nvim_buf_get_option(0, 'filetype') == 'dapui_watches'
|
||||||
|
or vim.api.nvim_buf_get_option(0, 'filetype') == 'dapui_hover'
|
||||||
|
end,
|
||||||
|
completion = { completeopt = 'menu,menuone,noinsert, noselect' },
|
||||||
|
window = {
|
||||||
|
-- completion = cmp.config.window.bordered(),
|
||||||
|
-- documentation = cmp.config.window.bordered(),
|
||||||
|
},
|
||||||
|
sorting = {
|
||||||
|
comparators = {
|
||||||
|
require('clangd_extensions.cmp_scores'),
|
||||||
|
cmp.config.compare.locality,
|
||||||
|
-- cmp.config.compare.recently_used,
|
||||||
|
-- -- cmp.config.compare.offset,
|
||||||
|
-- cmp.config.compare.exact,
|
||||||
|
-- cmp.config.compare.recently_used,
|
||||||
|
-- cmp.config.compare.kind,
|
||||||
|
-- cmp.config.compare.sort_text,
|
||||||
|
-- cmp.config.compare.length,
|
||||||
|
-- cmp.config.compare.order,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
-- experimental = { native_menu = true }
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
||||||
|
cmp.setup.cmdline('/', {
|
||||||
|
sources = {
|
||||||
|
{ name = 'buffer' },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||||
|
cmp.setup.cmdline(':', {
|
||||||
|
sources = {
|
||||||
|
{ name = 'cmdline' },
|
||||||
|
{ name = 'cmdline_history' },
|
||||||
|
{ name = 'path' },
|
||||||
|
{ name = 'buffer' },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
require('cmp').setup.filetype({ 'dap-repl', 'dapui_watches', 'dapui_hover' }, {
|
||||||
|
sources = {
|
||||||
|
{ name = 'dap' },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Autopairs
|
||||||
|
--require("nvim-autopairs.completion.cmp").setup({
|
||||||
|
-- map_cr = true,
|
||||||
|
-- map_complete = true,
|
||||||
|
-- auto_select = true
|
||||||
|
--})
|
||||||
|
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||||
|
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } }))
|
||||||
|
end,
|
||||||
|
event = { 'InsertEnter', 'CmdLineEnter' },
|
||||||
|
}
|
22
lua/plugins/comment.lua
Normal file
22
lua/plugins/comment.lua
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
return {
|
||||||
|
'numToStr/Comment.nvim',
|
||||||
|
config = function()
|
||||||
|
require('Comment').setup({
|
||||||
|
mappings = false,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
keys = {
|
||||||
|
{
|
||||||
|
'<c-c>',
|
||||||
|
'<Plug>(comment_toggle_linewise_current)',
|
||||||
|
desc= 'Toggle comment'
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
'<c-c>',
|
||||||
|
'<Plug>(comment_toggle_linewise_visual)gv',
|
||||||
|
mode = 'v',
|
||||||
|
desc= 'Toggle comment'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
lua/plugins/gitsigns.lua
Normal file
12
lua/plugins/gitsigns.lua
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
return {
|
||||||
|
'lewis6991/gitsigns.nvim',
|
||||||
|
config = {
|
||||||
|
current_line_blame = false,
|
||||||
|
current_line_blame_opts = {
|
||||||
|
virt_text = true,
|
||||||
|
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
|
||||||
|
delay = 1000,
|
||||||
|
ignore_whitespace = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
20
lua/plugins/indent_blankline.lua
Normal file
20
lua/plugins/indent_blankline.lua
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
return {
|
||||||
|
'lukas-reineke/indent-blankline.nvim',
|
||||||
|
dependencies = {
|
||||||
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local opt = vim.opt -- to set options
|
||||||
|
opt.listchars:append('eol:↴')
|
||||||
|
-- opt.listchars:append("space: ")
|
||||||
|
opt.listchars:append('trail: ')
|
||||||
|
opt.listchars:append('tab:→ ')
|
||||||
|
|
||||||
|
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' },
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
}
|
@ -21,108 +21,14 @@ return {
|
|||||||
},
|
},
|
||||||
keys = { '<leader>p', '<leader>i' }
|
keys = { '<leader>p', '<leader>i' }
|
||||||
},
|
},
|
||||||
{
|
|
||||||
'p00f/nvim-ts-rainbow',
|
|
||||||
dependencies = 'nvim-treesitter/nvim-treesitter',
|
|
||||||
event = 'VeryLazy'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'ahmedkhalf/project.nvim',
|
|
||||||
config = function()
|
|
||||||
require('setup/project')
|
|
||||||
end,
|
|
||||||
event = 'VeryLazy'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
'eddyekofo94/gruvbox-flat.nvim',
|
'eddyekofo94/gruvbox-flat.nvim',
|
||||||
disable = false,
|
disable = false,
|
||||||
|
priority = 1000,
|
||||||
config = function()
|
config = function()
|
||||||
require('setup/my_gruvbox_flat')
|
require('setup/my_gruvbox_flat')
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
{
|
|
||||||
'lukas-reineke/indent-blankline.nvim',
|
|
||||||
dependencies = {
|
|
||||||
'nvim-treesitter/nvim-treesitter',
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
require('setup/indent_blankline')
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'lewis6991/gitsigns.nvim',
|
|
||||||
config = function()
|
|
||||||
require('setup/gitsigns')
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'numToStr/Comment.nvim',
|
|
||||||
config = function()
|
|
||||||
require('setup/comment')
|
|
||||||
end,
|
|
||||||
keys = '<c-c>'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'hoob3rt/lualine.nvim',
|
|
||||||
dependencies = { 'kyazdani42/nvim-web-devicons' },
|
|
||||||
config = function()
|
|
||||||
require('setup/lualine')
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'hrsh7th/nvim-cmp',
|
|
||||||
dependencies = {
|
|
||||||
{ 'onsails/lspkind-nvim' },
|
|
||||||
{ 'hrsh7th/cmp-buffer' },
|
|
||||||
{ 'hrsh7th/cmp-nvim-lsp' },
|
|
||||||
{
|
|
||||||
'L3MON4D3/LuaSnip',
|
|
||||||
config = function()
|
|
||||||
require('setup/luasnip')
|
|
||||||
end,
|
|
||||||
dependencies =
|
|
||||||
{
|
|
||||||
'rafamadriz/friendly-snippets'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ 'saadparwaiz1/cmp_luasnip' },
|
|
||||||
{ 'hrsh7th/cmp-nvim-lua' },
|
|
||||||
{ 'octaltree/cmp-look' },
|
|
||||||
{ 'hrsh7th/cmp-path' },
|
|
||||||
{ 'hrsh7th/cmp-calc' },
|
|
||||||
{ 'f3fora/cmp-spell' },
|
|
||||||
{ 'hrsh7th/cmp-emoji' },
|
|
||||||
{ 'hrsh7th/cmp-cmdline' },
|
|
||||||
{ 'dmitmel/cmp-cmdline-history' },
|
|
||||||
{ 'ray-x/cmp-treesitter' },
|
|
||||||
{ 'hrsh7th/cmp-nvim-lsp-signature-help' },
|
|
||||||
{ 'p00f/clangd_extensions.nvim' },
|
|
||||||
{
|
|
||||||
'windwp/nvim-autopairs',
|
|
||||||
config = function()
|
|
||||||
require('setup/nvim-autopairs')
|
|
||||||
end
|
|
||||||
},
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
require('setup/my_cmp')
|
|
||||||
end,
|
|
||||||
event = { 'InsertEnter', 'CmdLineEnter' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'neovim/nvim-lspconfig',
|
|
||||||
dependencies = {
|
|
||||||
'williamboman/mason.nvim',
|
|
||||||
'williamboman/mason-lspconfig.nvim',
|
|
||||||
'p00f/clangd_extensions.nvim',
|
|
||||||
'jose-elias-alvarez/null-ls.nvim',
|
|
||||||
'ray-x/lsp_signature.nvim',
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
require('setup/my_lspconfig')
|
|
||||||
end,
|
|
||||||
event = 'VeryLazy'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
'akinsho/toggleterm.nvim',
|
'akinsho/toggleterm.nvim',
|
||||||
config = function()
|
config = function()
|
||||||
|
231
lua/plugins/lspconfig.lua
Normal file
231
lua/plugins/lspconfig.lua
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
return {
|
||||||
|
'neovim/nvim-lspconfig',
|
||||||
|
dependencies = {
|
||||||
|
'williamboman/mason.nvim',
|
||||||
|
'williamboman/mason-lspconfig.nvim',
|
||||||
|
'p00f/clangd_extensions.nvim',
|
||||||
|
'jose-elias-alvarez/null-ls.nvim',
|
||||||
|
'ray-x/lsp_signature.nvim',
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require('mason').setup()
|
||||||
|
require('mason-lspconfig').setup({
|
||||||
|
automatic_installation = false,
|
||||||
|
})
|
||||||
|
|
||||||
|
local capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
||||||
|
|
||||||
|
OpenDiagFloat = function()
|
||||||
|
for _, winid in pairs(vim.api.nvim_tabpage_list_wins(0)) do
|
||||||
|
if vim.api.nvim_win_get_config(winid).zindex then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
vim.diagnostic.open_float({ focusable = false, width = 80 })
|
||||||
|
end
|
||||||
|
|
||||||
|
local on_attach = function(client, bufnr)
|
||||||
|
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 = false, buffer = bufnr }
|
||||||
|
vim.keymap.set('n', '<space>,', vim.diagnostic.goto_prev, opts)
|
||||||
|
vim.keymap.set('n', '<space>;', vim.diagnostic.goto_next, opts)
|
||||||
|
vim.keymap.set('n', '<space>a', vim.lsp.buf.code_action, opts)
|
||||||
|
vim.keymap.set('n', '<space>d', vim.lsp.buf.definition, opts)
|
||||||
|
vim.keymap.set('n', '<space>e', vim.lsp.buf.declaration, opts)
|
||||||
|
vim.keymap.set('n', '<space>h', vim.lsp.buf.hover, opts)
|
||||||
|
vim.keymap.set('n', '<space>c', vim.lsp.buf.outgoing_calls, opts)
|
||||||
|
vim.keymap.set('n', '<space>C', vim.lsp.buf.incoming_calls, opts)
|
||||||
|
vim.keymap.set('n', '<space>m', vim.lsp.buf.rename, opts)
|
||||||
|
local tele_builtins = require('telescope.builtin')
|
||||||
|
vim.keymap.set('n', '<C-t>', tele_builtins.lsp_dynamic_workspace_symbols, opts)
|
||||||
|
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
|
||||||
|
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
||||||
|
vim.keymap.set('n', '<space>r', tele_builtins.lsp_references, opts)
|
||||||
|
vim.keymap.set('n', '<A-m>', '<cmd>Telescope aerial<cr>', opts)
|
||||||
|
vim.keymap.set('n', '<space>v', function() tele_builtins.diagnostics({ bufnr = 0 }) end, opts)
|
||||||
|
vim.keymap.set('n', '<A-o>', '<cmd>ClangdSwitchSourceHeader<CR>', opts)
|
||||||
|
|
||||||
|
vim.cmd([[autocmd CursorHold <buffer> lua OpenDiagFloat()]])
|
||||||
|
|
||||||
|
-- Set some keybinds conditional on server capabilities
|
||||||
|
if client.server_capabilities.documentFormattingProvider then
|
||||||
|
vim.keymap.set('n', '<space>f', vim.lsp.buf.format, opts)
|
||||||
|
end
|
||||||
|
if client.server_capabilities.documentRangeFormattingProvider then
|
||||||
|
vim.keymap.set('x', '<space>f', vim.lsp.buf.format, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set autocommands conditional on server_capabilities
|
||||||
|
if client.server_capabilities.documentHighlightProvider then
|
||||||
|
vim.api.nvim_set_hl(
|
||||||
|
0,
|
||||||
|
"LspReferenceText",
|
||||||
|
{ bold = true,
|
||||||
|
ctermbg = 'red',
|
||||||
|
bg = "#5a524c" }
|
||||||
|
)
|
||||||
|
vim.api.nvim_set_hl(
|
||||||
|
0,
|
||||||
|
"LspReferenceRead",
|
||||||
|
{ bold = true,
|
||||||
|
ctermbg = 'red',
|
||||||
|
bg = 'DarkGreen' }
|
||||||
|
)
|
||||||
|
vim.api.nvim_set_hl(
|
||||||
|
0,
|
||||||
|
"LspReferenceWrite",
|
||||||
|
{ bold = true,
|
||||||
|
ctermbg = 'red',
|
||||||
|
bg = 'DarkRed' }
|
||||||
|
)
|
||||||
|
vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true })
|
||||||
|
vim.api.nvim_clear_autocmds { buffer = bufnr, group = "lsp_document_highlight" }
|
||||||
|
vim.api.nvim_create_autocmd("CursorHold", {
|
||||||
|
callback = vim.lsp.buf.document_highlight,
|
||||||
|
buffer = bufnr,
|
||||||
|
group = "lsp_document_highlight",
|
||||||
|
desc = "Document Highlight",
|
||||||
|
})
|
||||||
|
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||||
|
callback = vim.lsp.buf.clear_references,
|
||||||
|
buffer = bufnr,
|
||||||
|
group = "lsp_document_highlight",
|
||||||
|
desc = "Clear All the References",
|
||||||
|
})
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
|
||||||
|
require('lspconfig')['pyright'].setup {
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
}
|
||||||
|
|
||||||
|
require('lspconfig')['groovyls'].setup {
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
}
|
||||||
|
|
||||||
|
require('lspconfig')['cmake'].setup {
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
}
|
||||||
|
|
||||||
|
local clangd_capabilities = capabilities
|
||||||
|
clangd_capabilities.textDocument.semanticHighlighting = true
|
||||||
|
clangd_capabilities.offsetEncoding = { "utf-16" }
|
||||||
|
require("clangd_extensions").setup {
|
||||||
|
server = {
|
||||||
|
capabilities = clangd_capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
cmd = { 'clangd', '--compile-commands-dir=build_nvim' },
|
||||||
|
root_dir = require('lspconfig').util.root_pattern(
|
||||||
|
'.clangd',
|
||||||
|
'.clang-tidy',
|
||||||
|
'.clang-format',
|
||||||
|
'compile_commands.json',
|
||||||
|
'compile_flags.txt',
|
||||||
|
'configure.ac',
|
||||||
|
'.git',
|
||||||
|
'build_nvim'
|
||||||
|
)
|
||||||
|
},
|
||||||
|
extensions =
|
||||||
|
{
|
||||||
|
inlay_hints = {
|
||||||
|
-- Only show inlay hints for the current line
|
||||||
|
only_current_line = true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
-- require('clangd_extensions').setup({
|
||||||
|
-- server = {
|
||||||
|
-- on_attach = on_attach,
|
||||||
|
-- capabilities = capabilities,
|
||||||
|
-- cmd = { 'clangd', '--compile-commands-dir=build_nvim' },
|
||||||
|
-- },
|
||||||
|
-- })
|
||||||
|
|
||||||
|
require('lspconfig')['jsonls'].setup {
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
}
|
||||||
|
|
||||||
|
local lua_rtp = vim.split(package.path, ';')
|
||||||
|
table.insert(lua_rtp, 'lua/?.lua')
|
||||||
|
table.insert(lua_rtp, 'lua/?/init.lua')
|
||||||
|
require('lspconfig').sumneko_lua.setup {
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
runtime = {
|
||||||
|
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||||
|
version = 'LuaJIT',
|
||||||
|
-- Setup your lua path
|
||||||
|
path = lua_rtp,
|
||||||
|
},
|
||||||
|
diagnostics = {
|
||||||
|
-- Get the language server to recognize the `vim` global
|
||||||
|
globals = { 'vim', 'use' },
|
||||||
|
},
|
||||||
|
workspace = {
|
||||||
|
-- Make the server aware of Neovim runtime files
|
||||||
|
library = vim.api.nvim_get_runtime_file('', true),
|
||||||
|
},
|
||||||
|
-- Do not send telemetry data containing a randomized but unique identifier
|
||||||
|
telemetry = {
|
||||||
|
enable = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require('lspconfig')['dockerls'].setup {
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
}
|
||||||
|
|
||||||
|
require('lspconfig')['yamlls'].setup {
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
settings = {
|
||||||
|
yaml = {
|
||||||
|
validate = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
local null_ls = require('null-ls')
|
||||||
|
null_ls.setup({
|
||||||
|
sources = {
|
||||||
|
null_ls.builtins.code_actions.gitsigns,
|
||||||
|
null_ls.builtins.formatting.autopep8,
|
||||||
|
null_ls.builtins.formatting.prettier,
|
||||||
|
null_ls.builtins.diagnostics.flake8,
|
||||||
|
null_ls.builtins.formatting.isort,
|
||||||
|
null_ls.builtins.formatting.cmake_format,
|
||||||
|
},
|
||||||
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.diagnostic.config({ virtual_text = false })
|
||||||
|
end,
|
||||||
|
event = 'VeryLazy'
|
||||||
|
}
|
32
lua/plugins/lualine.lua
Normal file
32
lua/plugins/lualine.lua
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
return {
|
||||||
|
'hoob3rt/lualine.nvim',
|
||||||
|
dependencies = { 'kyazdani42/nvim-web-devicons' },
|
||||||
|
config = {
|
||||||
|
options = {
|
||||||
|
theme = 'gruvbox-flat',
|
||||||
|
disabled_filetypes = {
|
||||||
|
statusline = {},
|
||||||
|
winbar = { 'dap-repl', 'dapui_console' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
sections = { lualine_c = { 'getcwd', { 'filename', path = 1, file_status = true } } },
|
||||||
|
inactive_sections = { lualine_c = { 'getcwd', { 'filename', path = 1, file_status = true } } },
|
||||||
|
globalstatus = true,
|
||||||
|
winbar = {
|
||||||
|
lualine_a = {},
|
||||||
|
lualine_b = {},
|
||||||
|
lualine_c = { { 'filename', path = 1, file_status = true } },
|
||||||
|
lualine_x = {},
|
||||||
|
lualine_y = {},
|
||||||
|
lualine_z = {}
|
||||||
|
},
|
||||||
|
inactive_winbar = {
|
||||||
|
lualine_a = {},
|
||||||
|
lualine_b = {},
|
||||||
|
lualine_c = { { 'filename', path = 1, file_status = true } },
|
||||||
|
lualine_x = {},
|
||||||
|
lualine_y = {},
|
||||||
|
lualine_z = {}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
5
lua/plugins/nvim-ts-rainbow.lua
Normal file
5
lua/plugins/nvim-ts-rainbow.lua
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
return {
|
||||||
|
'p00f/nvim-ts-rainbow',
|
||||||
|
dependencies = 'nvim-treesitter/nvim-treesitter',
|
||||||
|
event = 'VeryLazy'
|
||||||
|
}
|
12
lua/plugins/project.lua
Normal file
12
lua/plugins/project.lua
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
return {
|
||||||
|
'ahmedkhalf/project.nvim',
|
||||||
|
config = function()
|
||||||
|
require("project_nvim").setup(
|
||||||
|
{
|
||||||
|
silent_chdir = true,
|
||||||
|
ignore_lsp = { 'null-ls', 'cmake' },
|
||||||
|
patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json", "build_nvim", "real_path.txt" },
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
-- event = 'BufReadPre'
|
||||||
|
}
|
@ -5,15 +5,14 @@ return {
|
|||||||
'kyazdani42/nvim-web-devicons',
|
'kyazdani42/nvim-web-devicons',
|
||||||
{
|
{
|
||||||
'nvim-telescope/telescope-fzf-native.nvim',
|
'nvim-telescope/telescope-fzf-native.nvim',
|
||||||
'nvim-telescope/telescope-ui-select.nvim',
|
|
||||||
build = {
|
build = {
|
||||||
'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -G Ninja', -- On windows add -DCMAKE_C_FLAGS="-target x86_64-w64-mingw32"
|
'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -G Ninja', -- On windows add -DCMAKE_C_FLAGS="-target x86_64-w64-mingw32"
|
||||||
'cmake --build build --config Release',
|
'cmake --build build --config Release',
|
||||||
'cmake --install build --prefix build'
|
'cmake --install build --prefix build'
|
||||||
},
|
},
|
||||||
config = function()
|
|
||||||
end
|
|
||||||
},
|
},
|
||||||
|
'nvim-telescope/telescope-ui-select.nvim',
|
||||||
|
'ahmedkhalf/project.nvim',
|
||||||
},
|
},
|
||||||
cmd = { "Telescope" },
|
cmd = { "Telescope" },
|
||||||
keys = {
|
keys = {
|
||||||
@ -86,7 +85,14 @@ return {
|
|||||||
require("telescope.builtin").grep_string()
|
require("telescope.builtin").grep_string()
|
||||||
end,
|
end,
|
||||||
desc = 'Find in workspace',
|
desc = 'Find in workspace',
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
'<space>p',
|
||||||
|
function()
|
||||||
|
require('telescope').extensions.projects.projects()
|
||||||
|
end,
|
||||||
|
desc = 'Select project',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
local actions = require('telescope.actions')
|
local actions = require('telescope.actions')
|
||||||
@ -98,6 +104,12 @@ return {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Project_files = function()
|
||||||
|
local opts = {} -- define here if you want to define something
|
||||||
|
local ok = pcall(require "telescope.builtin".git_files, opts)
|
||||||
|
if not ok then require "telescope.builtin".find_files(opts) end
|
||||||
|
end
|
||||||
|
|
||||||
require('telescope').setup({
|
require('telescope').setup({
|
||||||
defaults = {
|
defaults = {
|
||||||
mappings = {
|
mappings = {
|
||||||
@ -149,13 +161,7 @@ return {
|
|||||||
})
|
})
|
||||||
|
|
||||||
require("telescope").load_extension("ui-select")
|
require("telescope").load_extension("ui-select")
|
||||||
|
|
||||||
Project_files = function()
|
|
||||||
local opts = {} -- define here if you want to define something
|
|
||||||
local ok = pcall(require "telescope.builtin".git_files, opts)
|
|
||||||
if not ok then require "telescope.builtin".find_files(opts) end
|
|
||||||
end
|
|
||||||
|
|
||||||
require('telescope').load_extension('fzf')
|
require('telescope').load_extension('fzf')
|
||||||
|
-- require('telescope').load_extension('projects')
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
require('Comment').setup({
|
|
||||||
mappings = false,
|
|
||||||
})
|
|
||||||
require('legendary').keymap(
|
|
||||||
{
|
|
||||||
'<c-c>',
|
|
||||||
{
|
|
||||||
n = '<Plug>(comment_toggle_linewise_current)',
|
|
||||||
v = '<Plug>(comment_toggle_linewise_visual)gv'
|
|
||||||
},
|
|
||||||
description = 'Toggle comment'
|
|
||||||
}
|
|
||||||
)
|
|
@ -1,9 +0,0 @@
|
|||||||
require('gitsigns').setup({
|
|
||||||
current_line_blame = false,
|
|
||||||
current_line_blame_opts = {
|
|
||||||
virt_text = true,
|
|
||||||
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
|
|
||||||
delay = 1000,
|
|
||||||
ignore_whitespace = false,
|
|
||||||
},
|
|
||||||
})
|
|
@ -1,12 +0,0 @@
|
|||||||
local opt = vim.opt -- to set options
|
|
||||||
opt.listchars:append('eol:↴')
|
|
||||||
-- opt.listchars:append("space: ")
|
|
||||||
opt.listchars:append('trail: ')
|
|
||||||
opt.listchars:append('tab:→ ')
|
|
||||||
|
|
||||||
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' },
|
|
||||||
})
|
|
@ -1,29 +0,0 @@
|
|||||||
vim.opt.laststatus = 3
|
|
||||||
require('lualine').setup({
|
|
||||||
options = {
|
|
||||||
theme = 'gruvbox-flat',
|
|
||||||
disabled_filetypes = {
|
|
||||||
statusline = {},
|
|
||||||
winbar = { 'dap-repl', 'dapui_console' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
sections = { lualine_c = { 'getcwd', { 'filename', path = 1, file_status = true } } },
|
|
||||||
inactive_sections = { lualine_c = { 'getcwd', { 'filename', path = 1, file_status = true } } },
|
|
||||||
globalstatus = true,
|
|
||||||
winbar = {
|
|
||||||
lualine_a = {},
|
|
||||||
lualine_b = {},
|
|
||||||
lualine_c = { { 'filename', path = 1, file_status = true } },
|
|
||||||
lualine_x = {},
|
|
||||||
lualine_y = {},
|
|
||||||
lualine_z = {}
|
|
||||||
},
|
|
||||||
inactive_winbar = {
|
|
||||||
lualine_a = {},
|
|
||||||
lualine_b = {},
|
|
||||||
lualine_c = { { 'filename', path = 1, file_status = true } },
|
|
||||||
lualine_x = {},
|
|
||||||
lualine_y = {},
|
|
||||||
lualine_z = {}
|
|
||||||
},
|
|
||||||
})
|
|
@ -1,141 +0,0 @@
|
|||||||
local cmp = require('cmp')
|
|
||||||
local luasnip = require('luasnip')
|
|
||||||
|
|
||||||
local t = function(str)
|
|
||||||
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
|
|
||||||
end
|
|
||||||
|
|
||||||
cmp.setup({
|
|
||||||
formatting = {
|
|
||||||
format = require('lspkind').cmp_format({
|
|
||||||
mode = 'symbol_text', -- show only symbol annotations
|
|
||||||
maxwidth = 80, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
|
|
||||||
ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
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 = false }),
|
|
||||||
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)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
sources = {
|
|
||||||
{ name = 'luasnip', priority = 8 },
|
|
||||||
{ name = 'nvim_lsp', priority = 7 },
|
|
||||||
{ name = 'nvim_lsp_signature_help', priority = 7 },
|
|
||||||
{ name = 'treesitter', priority = 6 },
|
|
||||||
{ name = 'buffer', priority = 5,
|
|
||||||
option = {
|
|
||||||
get_bufnrs = function()
|
|
||||||
local bufs = {}
|
|
||||||
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
|
||||||
bufs[vim.api.nvim_win_get_buf(win)] = true
|
|
||||||
end
|
|
||||||
return vim.tbl_keys(bufs)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
},
|
|
||||||
-- { name = 'nvim_lua' },
|
|
||||||
-- { name = 'look' },
|
|
||||||
-- { name = 'path' },
|
|
||||||
-- { name = 'cmp_tabnine' },
|
|
||||||
-- { name = 'calc' },
|
|
||||||
-- { name = 'spell' },
|
|
||||||
-- { name = 'emoji' },
|
|
||||||
},
|
|
||||||
enabled = function()
|
|
||||||
return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt"
|
|
||||||
or vim.api.nvim_buf_get_option(0, 'filetype') == 'dap-repl'
|
|
||||||
or vim.api.nvim_buf_get_option(0, 'filetype') == 'dapui_watches'
|
|
||||||
or vim.api.nvim_buf_get_option(0, 'filetype') == 'dapui_hover'
|
|
||||||
end,
|
|
||||||
completion = { completeopt = 'menu,menuone,noinsert, noselect' },
|
|
||||||
window = {
|
|
||||||
-- completion = cmp.config.window.bordered(),
|
|
||||||
-- documentation = cmp.config.window.bordered(),
|
|
||||||
},
|
|
||||||
sorting = {
|
|
||||||
comparators = {
|
|
||||||
require('clangd_extensions.cmp_scores'),
|
|
||||||
cmp.config.compare.locality,
|
|
||||||
-- cmp.config.compare.recently_used,
|
|
||||||
-- -- cmp.config.compare.offset,
|
|
||||||
-- cmp.config.compare.exact,
|
|
||||||
-- cmp.config.compare.recently_used,
|
|
||||||
-- cmp.config.compare.kind,
|
|
||||||
-- cmp.config.compare.sort_text,
|
|
||||||
-- cmp.config.compare.length,
|
|
||||||
-- cmp.config.compare.order,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
-- experimental = { native_menu = true }
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
|
||||||
cmp.setup.cmdline('/', {
|
|
||||||
sources = {
|
|
||||||
{ name = 'buffer' },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
|
||||||
cmp.setup.cmdline(':', {
|
|
||||||
sources = {
|
|
||||||
{ name = 'cmdline' },
|
|
||||||
{ name = 'cmdline_history' },
|
|
||||||
{ name = 'path' },
|
|
||||||
{ name = 'buffer' },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
require('cmp').setup.filetype({ 'dap-repl', 'dapui_watches', 'dapui_hover' }, {
|
|
||||||
sources = {
|
|
||||||
{ name = 'dap' },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Autopairs
|
|
||||||
--require("nvim-autopairs.completion.cmp").setup({
|
|
||||||
-- map_cr = true,
|
|
||||||
-- map_complete = true,
|
|
||||||
-- auto_select = true
|
|
||||||
--})
|
|
||||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
|
||||||
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } }))
|
|
@ -1,218 +0,0 @@
|
|||||||
require('mason').setup()
|
|
||||||
require('mason-lspconfig').setup({
|
|
||||||
automatic_installation = false,
|
|
||||||
})
|
|
||||||
|
|
||||||
local capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
|
||||||
|
|
||||||
OpenDiagFloat = function()
|
|
||||||
for _, winid in pairs(vim.api.nvim_tabpage_list_wins(0)) do
|
|
||||||
if vim.api.nvim_win_get_config(winid).zindex then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
vim.diagnostic.open_float({ focusable = false, width=80 })
|
|
||||||
end
|
|
||||||
|
|
||||||
local on_attach = function(client, bufnr)
|
|
||||||
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 = false, buffer = bufnr }
|
|
||||||
vim.keymap.set('n', '<space>,', vim.diagnostic.goto_prev, opts)
|
|
||||||
vim.keymap.set('n', '<space>;', vim.diagnostic.goto_next, opts)
|
|
||||||
vim.keymap.set('n', '<space>a', vim.lsp.buf.code_action, opts)
|
|
||||||
vim.keymap.set('n', '<space>d', vim.lsp.buf.definition, opts)
|
|
||||||
vim.keymap.set('n', '<space>e', vim.lsp.buf.declaration, opts)
|
|
||||||
vim.keymap.set('n', '<space>h', vim.lsp.buf.hover, opts)
|
|
||||||
vim.keymap.set('n', '<space>c', vim.lsp.buf.outgoing_calls, opts)
|
|
||||||
vim.keymap.set('n', '<space>C', vim.lsp.buf.incoming_calls, opts)
|
|
||||||
vim.keymap.set('n', '<space>m', vim.lsp.buf.rename, opts)
|
|
||||||
local tele_builtins = require('telescope.builtin')
|
|
||||||
vim.keymap.set('n', '<C-t>', tele_builtins.lsp_dynamic_workspace_symbols, opts)
|
|
||||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
|
|
||||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
|
||||||
vim.keymap.set('n', '<space>r', tele_builtins.lsp_references, opts)
|
|
||||||
vim.keymap.set('n', '<A-m>', '<cmd>Telescope aerial<cr>', opts)
|
|
||||||
vim.keymap.set('n', '<space>v', function() tele_builtins.diagnostics({ bufnr = 0 }) end, opts)
|
|
||||||
vim.keymap.set('n', '<A-o>', '<cmd>ClangdSwitchSourceHeader<CR>', opts)
|
|
||||||
|
|
||||||
vim.cmd([[autocmd CursorHold <buffer> lua OpenDiagFloat()]])
|
|
||||||
|
|
||||||
-- Set some keybinds conditional on server capabilities
|
|
||||||
if client.server_capabilities.documentFormattingProvider then
|
|
||||||
vim.keymap.set('n', '<space>f', vim.lsp.buf.format, opts)
|
|
||||||
end
|
|
||||||
if client.server_capabilities.documentRangeFormattingProvider then
|
|
||||||
vim.keymap.set('x', '<space>f', vim.lsp.buf.format, opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Set autocommands conditional on server_capabilities
|
|
||||||
if client.server_capabilities.documentHighlightProvider then
|
|
||||||
vim.api.nvim_set_hl(
|
|
||||||
0,
|
|
||||||
"LspReferenceText",
|
|
||||||
{ bold = true,
|
|
||||||
ctermbg = 'red',
|
|
||||||
bg = "#5a524c"}
|
|
||||||
)
|
|
||||||
vim.api.nvim_set_hl(
|
|
||||||
0,
|
|
||||||
"LspReferenceRead",
|
|
||||||
{ bold = true,
|
|
||||||
ctermbg = 'red',
|
|
||||||
bg = 'DarkGreen' }
|
|
||||||
)
|
|
||||||
vim.api.nvim_set_hl(
|
|
||||||
0,
|
|
||||||
"LspReferenceWrite",
|
|
||||||
{ bold = true,
|
|
||||||
ctermbg = 'red',
|
|
||||||
bg = 'DarkRed' }
|
|
||||||
)
|
|
||||||
vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true })
|
|
||||||
vim.api.nvim_clear_autocmds { buffer = bufnr, group = "lsp_document_highlight" }
|
|
||||||
vim.api.nvim_create_autocmd("CursorHold", {
|
|
||||||
callback = vim.lsp.buf.document_highlight,
|
|
||||||
buffer = bufnr,
|
|
||||||
group = "lsp_document_highlight",
|
|
||||||
desc = "Document Highlight",
|
|
||||||
})
|
|
||||||
vim.api.nvim_create_autocmd("CursorMoved", {
|
|
||||||
callback = vim.lsp.buf.clear_references,
|
|
||||||
buffer = bufnr,
|
|
||||||
group = "lsp_document_highlight",
|
|
||||||
desc = "Clear All the References",
|
|
||||||
})
|
|
||||||
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)
|
|
||||||
end
|
|
||||||
|
|
||||||
require('lspconfig')['pyright'].setup {
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
}
|
|
||||||
|
|
||||||
require('lspconfig')['groovyls'].setup {
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
}
|
|
||||||
|
|
||||||
require('lspconfig')['cmake'].setup {
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
}
|
|
||||||
|
|
||||||
local clangd_capabilities = capabilities
|
|
||||||
clangd_capabilities.textDocument.semanticHighlighting = true
|
|
||||||
clangd_capabilities.offsetEncoding = { "utf-16" }
|
|
||||||
require("clangd_extensions").setup {
|
|
||||||
server = {
|
|
||||||
capabilities = clangd_capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
cmd = { 'clangd', '--compile-commands-dir=build_nvim' },
|
|
||||||
root_dir = require('lspconfig').util.root_pattern(
|
|
||||||
'.clangd',
|
|
||||||
'.clang-tidy',
|
|
||||||
'.clang-format',
|
|
||||||
'compile_commands.json',
|
|
||||||
'compile_flags.txt',
|
|
||||||
'configure.ac',
|
|
||||||
'.git',
|
|
||||||
'build_nvim'
|
|
||||||
)
|
|
||||||
},
|
|
||||||
extensions =
|
|
||||||
{
|
|
||||||
inlay_hints = {
|
|
||||||
-- Only show inlay hints for the current line
|
|
||||||
only_current_line = true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-- require('clangd_extensions').setup({
|
|
||||||
-- server = {
|
|
||||||
-- on_attach = on_attach,
|
|
||||||
-- capabilities = capabilities,
|
|
||||||
-- cmd = { 'clangd', '--compile-commands-dir=build_nvim' },
|
|
||||||
-- },
|
|
||||||
-- })
|
|
||||||
|
|
||||||
require('lspconfig')['jsonls'].setup {
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
}
|
|
||||||
|
|
||||||
local lua_rtp = vim.split(package.path, ';')
|
|
||||||
table.insert(lua_rtp, 'lua/?.lua')
|
|
||||||
table.insert(lua_rtp, 'lua/?/init.lua')
|
|
||||||
require('lspconfig').sumneko_lua.setup {
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
settings = {
|
|
||||||
Lua = {
|
|
||||||
runtime = {
|
|
||||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
|
||||||
version = 'LuaJIT',
|
|
||||||
-- Setup your lua path
|
|
||||||
path = lua_rtp,
|
|
||||||
},
|
|
||||||
diagnostics = {
|
|
||||||
-- Get the language server to recognize the `vim` global
|
|
||||||
globals = { 'vim', 'use' },
|
|
||||||
},
|
|
||||||
workspace = {
|
|
||||||
-- Make the server aware of Neovim runtime files
|
|
||||||
library = vim.api.nvim_get_runtime_file('', true),
|
|
||||||
},
|
|
||||||
-- Do not send telemetry data containing a randomized but unique identifier
|
|
||||||
telemetry = {
|
|
||||||
enable = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
require('lspconfig')['dockerls'].setup {
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
}
|
|
||||||
|
|
||||||
require('lspconfig')['yamlls'].setup {
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
settings = {
|
|
||||||
yaml = {
|
|
||||||
validate = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
local null_ls = require('null-ls')
|
|
||||||
null_ls.setup({
|
|
||||||
sources = {
|
|
||||||
null_ls.builtins.code_actions.gitsigns,
|
|
||||||
null_ls.builtins.formatting.autopep8,
|
|
||||||
null_ls.builtins.formatting.prettier,
|
|
||||||
null_ls.builtins.diagnostics.flake8,
|
|
||||||
null_ls.builtins.formatting.isort,
|
|
||||||
null_ls.builtins.formatting.cmake_format,
|
|
||||||
},
|
|
||||||
on_attach = on_attach,
|
|
||||||
capabilities = capabilities,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.diagnostic.config({ virtual_text = false })
|
|
@ -1,17 +0,0 @@
|
|||||||
require('project_nvim').setup({
|
|
||||||
silent_chdir = true,
|
|
||||||
ignore_lsp = { 'null-ls', 'cmake' },
|
|
||||||
patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json", "build_nvim", "real_path.txt" },
|
|
||||||
})
|
|
||||||
require('telescope').load_extension('projects')
|
|
||||||
require('legendary').keymaps(
|
|
||||||
{
|
|
||||||
{
|
|
||||||
'<space>p',
|
|
||||||
function ()
|
|
||||||
require('telescope').extensions.projects.projects()
|
|
||||||
end,
|
|
||||||
description = 'Select project',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
Loading…
x
Reference in New Issue
Block a user