From 88fce742fea734e6ad9fd3716e3f64161138926b Mon Sep 17 00:00:00 2001 From: Adam <56338480+adastx@users.noreply.github.com> Date: Tue, 3 May 2022 00:02:49 +0200 Subject: nvim: bufferline, nvim-tree, lsp, telescope, lualine --- .config/nvim/lua/options.lua | 1 + .config/nvim/lua/plugins.lua | 39 ++++++++++++++++++--------- .config/nvim/lua/setup/bufferline.lua | 11 ++++++++ .config/nvim/lua/setup/indent-blankline.lua | 3 ++- .config/nvim/lua/setup/lspconfig.lua | 30 +++++++++++++++++++++ .config/nvim/lua/setup/lualine.lua | 1 + .config/nvim/lua/setup/nvim-lsp-installer.lua | 31 --------------------- .config/nvim/lua/setup/nvim-tree.lua | 26 ++++++++++++++++++ .config/nvim/lua/setup/telescope.lua | 27 ++++++++++++++++++- 9 files changed, 124 insertions(+), 45 deletions(-) create mode 100644 .config/nvim/lua/setup/bufferline.lua create mode 100644 .config/nvim/lua/setup/lspconfig.lua delete mode 100644 .config/nvim/lua/setup/nvim-lsp-installer.lua create mode 100644 .config/nvim/lua/setup/nvim-tree.lua (limited to '.config') diff --git a/.config/nvim/lua/options.lua b/.config/nvim/lua/options.lua index 68d6705..55e32e7 100644 --- a/.config/nvim/lua/options.lua +++ b/.config/nvim/lua/options.lua @@ -34,6 +34,7 @@ set.pumblend = 0 set.splitright = true set.splitbelow = true set.cursorline = true +set.laststatus = 3 -- Disable default vim plugins local disabled_built_ins = { diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 1a2c5c3..e5aacb7 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -41,9 +41,25 @@ local plugins = { end, }, + { + "akinsho/bufferline.nvim", + after = "nvim-web-devicons", + config = function() + require "setup.bufferline" + end, + }, + + { + "kyazdani42/nvim-tree.lua", + cmd = { "NvimTreeToggle", "NvimTreeFindFile" }, + config = function() + require "setup.nvim-tree" + end, + }, + { "lukas-reineke/indent-blankline.nvim", - event = { "BufRead" , "BufNewFile" }, + event = { "BufRead", "BufNewFile" }, config = function() require "setup.indent-blankline" end, @@ -51,7 +67,7 @@ local plugins = { { "nvim-treesitter/nvim-treesitter", - event = { "BufRead" , "BufNewFile" }, + event = { "BufRead", "BufNewFile" }, config = function() require "setup.nvim-treesitter" end, @@ -60,7 +76,7 @@ local plugins = { { "lewis6991/gitsigns.nvim", - event = { "BufRead" , "BufNewFile" }, + event = { "BufRead", "BufNewFile" }, wants = "plenary.nvim", config = function() require('gitsigns').setup() @@ -71,14 +87,14 @@ local plugins = { { "neovim/nvim-lspconfig", - event = { "BufRead" , "BufNewFile" }, + event = { "BufRead", "BufNewFile" }, }, { "williamboman/nvim-lsp-installer", after = "nvim-lspconfig", config = function() - require "setup.nvim-lsp-installer" + require "setup.lspconfig" end, }, @@ -128,18 +144,18 @@ local plugins = { "windwp/nvim-autopairs", after = "nvim-cmp", config = function() - require('nvim-autopairs').setup{} + require('nvim-autopairs').setup {} end, }, { "tpope/vim-surround", - event = { "BufRead" , "BufNewFile" }, + event = { "BufRead", "BufNewFile" }, }, { "b3nj5m1n/kommentary", - event = { "BufRead" , "BufNewFile" }, + event = { "BufRead", "BufNewFile" }, config = function() require "setup.kommentary" end, @@ -175,10 +191,9 @@ local plugins = { { 'iamcco/markdown-preview.nvim', - cmd = { "MarkdownPreview" }, - ft = {'markdown'}, - run = function() - vim.fn['mkdp#util#install']() + ft = "markdown", + run = function() + vim.fn['mkdp#util#install']() end, }, } diff --git a/.config/nvim/lua/setup/bufferline.lua b/.config/nvim/lua/setup/bufferline.lua new file mode 100644 index 0000000..3dc0c71 --- /dev/null +++ b/.config/nvim/lua/setup/bufferline.lua @@ -0,0 +1,11 @@ +require("bufferline").setup { + options = { + offsets = { { + filetype = "NvimTree", + padding = 1, + } }, + diagnostics = "nvim_lsp", + tab_size = 20, + show_close_icon = false, + }, +} diff --git a/.config/nvim/lua/setup/indent-blankline.lua b/.config/nvim/lua/setup/indent-blankline.lua index 4a3c1e9..8e68947 100644 --- a/.config/nvim/lua/setup/indent-blankline.lua +++ b/.config/nvim/lua/setup/indent-blankline.lua @@ -12,7 +12,8 @@ require("indent_blankline").setup { "TelescopePrompt", "TelescopeResults", "lsp-installer", + "NvimTree", "", }, - buftype_exclude = { "terminal" }, + buftype_exclude = { "terminal", "NvimTree" }, } diff --git a/.config/nvim/lua/setup/lspconfig.lua b/.config/nvim/lua/setup/lspconfig.lua new file mode 100644 index 0000000..47fd84a --- /dev/null +++ b/.config/nvim/lua/setup/lspconfig.lua @@ -0,0 +1,30 @@ +require("nvim-lsp-installer").setup {} +local lspconfig = require("lspconfig") + +local function on_attach() + vim.cmd('doautocmd User lspAttached') + vim.cmd('augroup Format') + vim.cmd('autocmd! * ') + vim.cmd('autocmd BufWritePre lua vim.lsp.buf.formatting_sync()') + vim.cmd('augroup END') +end + +lspconfig.sumneko_lua.setup { + on_attach = on_attach, + settings = { + Lua = { + diagnostics = { + globals = { 'vim' } + } + } + } +} +lspconfig.rust_analyzer.setup { + on_attach = on_attach, +} + +local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } +for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) +end diff --git a/.config/nvim/lua/setup/lualine.lua b/.config/nvim/lua/setup/lualine.lua index 6304aa1..4d08844 100644 --- a/.config/nvim/lua/setup/lualine.lua +++ b/.config/nvim/lua/setup/lualine.lua @@ -5,6 +5,7 @@ require'lualine'.setup { component_separators = {left = '', right = ''}, section_separators = {left = '', right = ''}, disabled_filetypes = {'startify', 'terminal', 'netrw', 'NvimTree', 'packer'}, + globalstatus = true, }, sections = { lualine_a = {'mode'}, diff --git a/.config/nvim/lua/setup/nvim-lsp-installer.lua b/.config/nvim/lua/setup/nvim-lsp-installer.lua deleted file mode 100644 index edcc24d..0000000 --- a/.config/nvim/lua/setup/nvim-lsp-installer.lua +++ /dev/null @@ -1,31 +0,0 @@ -local lsp_installer = require("nvim-lsp-installer") - --- Register a handler that will be called for each installed server when it's ready (i.e. when installation is finished --- or if the server is already installed). -lsp_installer.on_server_ready(function(server) - local opts = { - on_attach = function() - vim.cmd('doautocmd User lspAttached') - vim.cmd('augroup Format') - vim.cmd('autocmd! * ') - vim.cmd('autocmd BufWritePre lua vim.lsp.buf.formatting_sync()') - vim.cmd('augroup END') - end, - } - - local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } - for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) - end - - -- (optional) Customize the options passed to the server - -- if server.name == "tsserver" then - -- opts.root_dir = function() ... end - -- end - - -- This setup() function will take the provided server configuration and decorate it with the necessary properties - -- before passing it onwards to lspconfig. - -- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md - server:setup(opts) -end) diff --git a/.config/nvim/lua/setup/nvim-tree.lua b/.config/nvim/lua/setup/nvim-tree.lua new file mode 100644 index 0000000..2903fb0 --- /dev/null +++ b/.config/nvim/lua/setup/nvim-tree.lua @@ -0,0 +1,26 @@ +vim.cmd('highlight NvimTreeIndentMarker guifg=#3b414c gui=nocombine') + +require 'nvim-tree'.setup { + hijack_cursor = true, + renderer = { + icons = { + webdev_colors = true, + }, + indent_markers = { + enable = true, + }, + }, + view = { + side = "left", + hide_root_folder = true, + }, + git = { + enable = false, + ignore = false, + }, + actions = { + open_file = { + resize_window = true, + }, + }, +} diff --git a/.config/nvim/lua/setup/telescope.lua b/.config/nvim/lua/setup/telescope.lua index a9dfeb3..da7a3ed 100644 --- a/.config/nvim/lua/setup/telescope.lua +++ b/.config/nvim/lua/setup/telescope.lua @@ -1,7 +1,32 @@ require("telescope").setup { defaults = { - path_display = { + path_display = { truncate = 3, }, + prompt_prefix = "  ", + selection_caret = " ", + entry_prefix = " ", + -- initial_mode = "insert", + -- selection_strategy = "reset", + -- sorting_strategy = "ascending", + -- layout_strategy = "horizontal", + -- layout_config = { + -- horizontal = { + -- prompt_position = "top", + -- preview_width = 0.55, + -- results_width = 0.8, + -- }, + -- vertical = { + -- mirror = false, + -- }, + -- width = 0.87, + -- height = 0.80, + -- preview_cutoff = 120, + -- }, + file_ignore_patterns = { "node_modules" }, + winblend = 0, + border = {}, + borderchars = { '─', '│', '─', '│', '┌', '┐', '┘', '└' }, + color_devicons = true, }, } -- cgit v1.2.3-70-g09d2