diff --git a/lua/config/options.lua b/lua/config/options.lua index ec3c295..e2aa99f 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -48,6 +48,7 @@ opt.expandtab= true opt.smartindent= true opt.title = true opt.titlestring = '%{getcwd()} - %t' +opt.laststatus = 3 -- for lualine -- go to previous/next line with h,l,left arrow and right arrow -- when cursor reaches end/beginning of line diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..1994d04 --- /dev/null +++ b/lua/plugins/cmp.lua @@ -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 = { + [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c', 's' }), + [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c', 's' }), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }), + [''] = cmp.mapping(cmp.mapping.close(), { 'i', 'c', 's' }), + [''] = cmp.mapping({ + i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }), + c = cmp.mapping.confirm({ select = false }), + s = cmp.mapping.confirm({ select = false }), + }), + [''] = cmp.mapping(function(fallback) + if luasnip.expand_or_jumpable() then + vim.api.nvim_feedkeys(t('luasnip-expand-or-jump'), '', true) + else + fallback() + end + end, { + 'i', + 's', + }), + [''] = cmp.mapping(function(fallback) + if luasnip.jumpable(-1) then + vim.api.nvim_feedkeys(t('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' }, +} diff --git a/lua/plugins/comment.lua b/lua/plugins/comment.lua new file mode 100644 index 0000000..c1eedc9 --- /dev/null +++ b/lua/plugins/comment.lua @@ -0,0 +1,22 @@ +return { + 'numToStr/Comment.nvim', + config = function() + require('Comment').setup({ + mappings = false, + }) + end, + keys = { + { + '', + '(comment_toggle_linewise_current)', + desc= 'Toggle comment' + }, + + { + '', + '(comment_toggle_linewise_visual)gv', + mode = 'v', + desc= 'Toggle comment' + } + } +} diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..27f6339 --- /dev/null +++ b/lua/plugins/gitsigns.lua @@ -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, + }, + } +} diff --git a/lua/plugins/indent_blankline.lua b/lua/plugins/indent_blankline.lua new file mode 100644 index 0000000..c7c41d0 --- /dev/null +++ b/lua/plugins/indent_blankline.lua @@ -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, +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 10e92d4..c039499 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -21,108 +21,14 @@ return { }, keys = { 'p', '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', disable = false, + priority = 1000, config = function() require('setup/my_gruvbox_flat') 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 = '' - }, - { - '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', config = function() diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua new file mode 100644 index 0000000..51f3dde --- /dev/null +++ b/lua/plugins/lspconfig.lua @@ -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', ',', vim.diagnostic.goto_prev, opts) + vim.keymap.set('n', ';', vim.diagnostic.goto_next, opts) + vim.keymap.set('n', 'a', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'e', vim.lsp.buf.declaration, opts) + vim.keymap.set('n', 'h', vim.lsp.buf.hover, opts) + vim.keymap.set('n', 'c', vim.lsp.buf.outgoing_calls, opts) + vim.keymap.set('n', 'C', vim.lsp.buf.incoming_calls, opts) + vim.keymap.set('n', 'm', vim.lsp.buf.rename, opts) + local tele_builtins = require('telescope.builtin') + vim.keymap.set('n', '', tele_builtins.lsp_dynamic_workspace_symbols, opts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) + vim.keymap.set('n', 'r', tele_builtins.lsp_references, opts) + vim.keymap.set('n', '', 'Telescope aerial', opts) + vim.keymap.set('n', 'v', function() tele_builtins.diagnostics({ bufnr = 0 }) end, opts) + vim.keymap.set('n', '', 'ClangdSwitchSourceHeader', opts) + + vim.cmd([[autocmd CursorHold lua OpenDiagFloat()]]) + + -- Set some keybinds conditional on server capabilities + if client.server_capabilities.documentFormattingProvider then + vim.keymap.set('n', 'f', vim.lsp.buf.format, opts) + end + if client.server_capabilities.documentRangeFormattingProvider then + vim.keymap.set('x', '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' +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..00731c2 --- /dev/null +++ b/lua/plugins/lualine.lua @@ -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 = {} + }, + } +} diff --git a/lua/plugins/nvim-ts-rainbow.lua b/lua/plugins/nvim-ts-rainbow.lua new file mode 100644 index 0000000..2c27644 --- /dev/null +++ b/lua/plugins/nvim-ts-rainbow.lua @@ -0,0 +1,5 @@ +return { + 'p00f/nvim-ts-rainbow', + dependencies = 'nvim-treesitter/nvim-treesitter', + event = 'VeryLazy' +} diff --git a/lua/plugins/project.lua b/lua/plugins/project.lua new file mode 100644 index 0000000..5330c8b --- /dev/null +++ b/lua/plugins/project.lua @@ -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' +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 4f40d42..b9e78a0 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -5,15 +5,14 @@ return { 'kyazdani42/nvim-web-devicons', { 'nvim-telescope/telescope-fzf-native.nvim', - 'nvim-telescope/telescope-ui-select.nvim', build = { '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 --install build --prefix build' }, - config = function() - end }, + 'nvim-telescope/telescope-ui-select.nvim', + 'ahmedkhalf/project.nvim', }, cmd = { "Telescope" }, keys = { @@ -86,7 +85,14 @@ return { require("telescope.builtin").grep_string() end, desc = 'Find in workspace', - } + }, + { + 'p', + function() + require('telescope').extensions.projects.projects() + end, + desc = 'Select project', + }, }, config = function() 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({ defaults = { mappings = { @@ -149,13 +161,7 @@ return { }) 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('projects') end } diff --git a/lua/setup/comment.lua b/lua/setup/comment.lua deleted file mode 100644 index 09302fb..0000000 --- a/lua/setup/comment.lua +++ /dev/null @@ -1,13 +0,0 @@ -require('Comment').setup({ - mappings = false, -}) -require('legendary').keymap( - { - '', - { - n = '(comment_toggle_linewise_current)', - v = '(comment_toggle_linewise_visual)gv' - }, - description = 'Toggle comment' - } -) diff --git a/lua/setup/gitsigns.lua b/lua/setup/gitsigns.lua deleted file mode 100644 index e4fb000..0000000 --- a/lua/setup/gitsigns.lua +++ /dev/null @@ -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, - }, -}) diff --git a/lua/setup/indent_blankline.lua b/lua/setup/indent_blankline.lua deleted file mode 100644 index fa14302..0000000 --- a/lua/setup/indent_blankline.lua +++ /dev/null @@ -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' }, -}) diff --git a/lua/setup/lualine.lua b/lua/setup/lualine.lua deleted file mode 100644 index a05db60..0000000 --- a/lua/setup/lualine.lua +++ /dev/null @@ -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 = {} - }, -}) diff --git a/lua/setup/my_cmp.lua b/lua/setup/my_cmp.lua deleted file mode 100644 index 6abbac6..0000000 --- a/lua/setup/my_cmp.lua +++ /dev/null @@ -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 = { - [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c', 's' }), - [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c', 's' }), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }), - [''] = cmp.mapping(cmp.mapping.close(), { 'i', 'c', 's' }), - [''] = cmp.mapping({ - i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }), - c = cmp.mapping.confirm({ select = false }), - s = cmp.mapping.confirm({ select = false }), - }), - [''] = cmp.mapping(function(fallback) - if luasnip.expand_or_jumpable() then - vim.api.nvim_feedkeys(t('luasnip-expand-or-jump'), '', true) - else - fallback() - end - end, { - 'i', - 's', - }), - [''] = cmp.mapping(function(fallback) - if luasnip.jumpable(-1) then - vim.api.nvim_feedkeys(t('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 = '' } })) diff --git a/lua/setup/my_lspconfig.lua b/lua/setup/my_lspconfig.lua deleted file mode 100644 index b16a0c0..0000000 --- a/lua/setup/my_lspconfig.lua +++ /dev/null @@ -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', ',', vim.diagnostic.goto_prev, opts) - vim.keymap.set('n', ';', vim.diagnostic.goto_next, opts) - vim.keymap.set('n', 'a', vim.lsp.buf.code_action, opts) - vim.keymap.set('n', 'd', vim.lsp.buf.definition, opts) - vim.keymap.set('n', 'e', vim.lsp.buf.declaration, opts) - vim.keymap.set('n', 'h', vim.lsp.buf.hover, opts) - vim.keymap.set('n', 'c', vim.lsp.buf.outgoing_calls, opts) - vim.keymap.set('n', 'C', vim.lsp.buf.incoming_calls, opts) - vim.keymap.set('n', 'm', vim.lsp.buf.rename, opts) - local tele_builtins = require('telescope.builtin') - vim.keymap.set('n', '', tele_builtins.lsp_dynamic_workspace_symbols, opts) - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) - vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) - vim.keymap.set('n', 'r', tele_builtins.lsp_references, opts) - vim.keymap.set('n', '', 'Telescope aerial', opts) - vim.keymap.set('n', 'v', function() tele_builtins.diagnostics({ bufnr = 0 }) end, opts) - vim.keymap.set('n', '', 'ClangdSwitchSourceHeader', opts) - - vim.cmd([[autocmd CursorHold lua OpenDiagFloat()]]) - - -- Set some keybinds conditional on server capabilities - if client.server_capabilities.documentFormattingProvider then - vim.keymap.set('n', 'f', vim.lsp.buf.format, opts) - end - if client.server_capabilities.documentRangeFormattingProvider then - vim.keymap.set('x', '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 }) diff --git a/lua/setup/project.lua b/lua/setup/project.lua deleted file mode 100644 index bc289c5..0000000 --- a/lua/setup/project.lua +++ /dev/null @@ -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( - { - { - 'p', - function () - require('telescope').extensions.projects.projects() - end, - description = 'Select project', - }, - } -)