aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksa Vučković <aleksav013@gmail.com>2022-01-18 01:31:23 +0100
committerAleksa Vučković <aleksav013@gmail.com>2022-01-18 01:31:23 +0100
commite056fe78a29edbe377445c0fcb5854bec122dee8 (patch)
tree108f09fbfe301568e2c9bd1fb22df2241fa93412
parent75177e174bd9d95937e3f4df1766ac28705b1f6a (diff)
ccls fixed, bufferline, nvim-tree
-rw-r--r--init.lua2
-rw-r--r--lua/user/bufferline.lua167
-rw-r--r--lua/user/keymaps.lua15
-rw-r--r--lua/user/lsp/ccls.lua (renamed from lua/user/lsp/settings/ccls.lua)5
-rw-r--r--lua/user/lsp/init.lua2
-rw-r--r--lua/user/nvim-tree.lua112
6 files changed, 295 insertions, 8 deletions
diff --git a/init.lua b/init.lua
index ed12066..62b4a51 100644
--- a/init.lua
+++ b/init.lua
@@ -4,3 +4,5 @@ require "user.plugins"
require "user.cmp"
require "user.autopairs"
require "user.lsp"
+require "user.nvim-tree"
+require "user.bufferline"
diff --git a/lua/user/bufferline.lua b/lua/user/bufferline.lua
new file mode 100644
index 0000000..74cdd33
--- /dev/null
+++ b/lua/user/bufferline.lua
@@ -0,0 +1,167 @@
+local status_ok, bufferline = pcall(require, "bufferline")
+if not status_ok then
+ return
+end
+
+bufferline.setup {
+ options = {
+ numbers = "none", -- | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string,
+ close_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions"
+ right_mouse_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions"
+ left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions"
+ middle_mouse_command = nil, -- can be a string | function, see "Mouse actions"
+ -- NOTE: this plugin is designed with this icon in mind,
+ -- and so changing this is NOT recommended, this is intended
+ -- as an escape hatch for people who cannot bear it for whatever reason
+ indicator_icon = "▎",
+ buffer_close_icon = "",
+ -- buffer_close_icon = '',
+ modified_icon = "●",
+ close_icon = "",
+ -- close_icon = '',
+ left_trunc_marker = "",
+ right_trunc_marker = "",
+ --- name_formatter can be used to change the buffer's label in the bufferline.
+ --- Please note some names can/will break the
+ --- bufferline so use this at your discretion knowing that it has
+ --- some limitations that will *NOT* be fixed.
+ -- name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr"
+ -- -- remove extension from markdown files for example
+ -- if buf.name:match('%.md') then
+ -- return vim.fn.fnamemodify(buf.name, ':t:r')
+ -- end
+ -- end,
+ max_name_length = 30,
+ max_prefix_length = 30, -- prefix used when a buffer is de-duplicated
+ tab_size = 21,
+ diagnostics = false, -- | "nvim_lsp" | "coc",
+ diagnostics_update_in_insert = false,
+ -- diagnostics_indicator = function(count, level, diagnostics_dict, context)
+ -- return "("..count..")"
+ -- end,
+ -- NOTE: this will be called a lot so don't do any heavy processing here
+ -- custom_filter = function(buf_number)
+ -- -- filter out filetypes you don't want to see
+ -- if vim.bo[buf_number].filetype ~= "<i-dont-want-to-see-this>" then
+ -- return true
+ -- end
+ -- -- filter out by buffer name
+ -- if vim.fn.bufname(buf_number) ~= "<buffer-name-I-dont-want>" then
+ -- return true
+ -- end
+ -- -- filter out based on arbitrary rules
+ -- -- e.g. filter out vim wiki buffer from tabline in your work repo
+ -- if vim.fn.getcwd() == "<work-repo>" and vim.bo[buf_number].filetype ~= "wiki" then
+ -- return true
+ -- end
+ -- end,
+ offsets = { { filetype = "NvimTree", text = "", padding = 1 } },
+ show_buffer_icons = true,
+ show_buffer_close_icons = true,
+ show_close_icon = true,
+ show_tab_indicators = true,
+ persist_buffer_sort = true, -- whether or not custom sorted buffers should persist
+ -- can also be a table containing 2 custom separators
+ -- [focused and unfocused]. eg: { '|', '|' }
+ separator_style = "thin", -- | "thick" | "thin" | { 'any', 'any' },
+ enforce_regular_tabs = true,
+ always_show_bufferline = true,
+ -- sort_by = 'id' | 'extension' | 'relative_directory' | 'directory' | 'tabs' | function(buffer_a, buffer_b)
+ -- -- add custom logic
+ -- return buffer_a.modified > buffer_b.modified
+ -- end
+ },
+ highlights = {
+ fill = {
+ guifg = { attribute = "fg", highlight = "#ff0000" },
+ guibg = { attribute = "bg", highlight = "TabLine" },
+ },
+ background = {
+ guifg = { attribute = "fg", highlight = "TabLine" },
+ guibg = { attribute = "bg", highlight = "TabLine" },
+ },
+
+ -- buffer_selected = {
+ -- guifg = {attribute='fg',highlight='#ff0000'},
+ -- guibg = {attribute='bg',highlight='#0000ff'},
+ -- gui = 'none'
+ -- },
+ buffer_visible = {
+ guifg = { attribute = "fg", highlight = "TabLine" },
+ guibg = { attribute = "bg", highlight = "TabLine" },
+ },
+
+ close_button = {
+ guifg = { attribute = "fg", highlight = "TabLine" },
+ guibg = { attribute = "bg", highlight = "TabLine" },
+ },
+ close_button_visible = {
+ guifg = { attribute = "fg", highlight = "TabLine" },
+ guibg = { attribute = "bg", highlight = "TabLine" },
+ },
+ -- close_button_selected = {
+ -- guifg = {attribute='fg',highlight='TabLineSel'},
+ -- guibg ={attribute='bg',highlight='TabLineSel'}
+ -- },
+
+ tab_selected = {
+ guifg = { attribute = "fg", highlight = "Normal" },
+ guibg = { attribute = "bg", highlight = "Normal" },
+ },
+ tab = {
+ guifg = { attribute = "fg", highlight = "TabLine" },
+ guibg = { attribute = "bg", highlight = "TabLine" },
+ },
+ tab_close = {
+ -- guifg = {attribute='fg',highlight='LspDiagnosticsDefaultError'},
+ guifg = { attribute = "fg", highlight = "TabLineSel" },
+ guibg = { attribute = "bg", highlight = "Normal" },
+ },
+
+ duplicate_selected = {
+ guifg = { attribute = "fg", highlight = "TabLineSel" },
+ guibg = { attribute = "bg", highlight = "TabLineSel" },
+ gui = "italic",
+ },
+ duplicate_visible = {
+ guifg = { attribute = "fg", highlight = "TabLine" },
+ guibg = { attribute = "bg", highlight = "TabLine" },
+ gui = "italic",
+ },
+ duplicate = {
+ guifg = { attribute = "fg", highlight = "TabLine" },
+ guibg = { attribute = "bg", highlight = "TabLine" },
+ gui = "italic",
+ },
+
+ modified = {
+ guifg = { attribute = "fg", highlight = "TabLine" },
+ guibg = { attribute = "bg", highlight = "TabLine" },
+ },
+ modified_selected = {
+ guifg = { attribute = "fg", highlight = "Normal" },
+ guibg = { attribute = "bg", highlight = "Normal" },
+ },
+ modified_visible = {
+ guifg = { attribute = "fg", highlight = "TabLine" },
+ guibg = { attribute = "bg", highlight = "TabLine" },
+ },
+
+ separator = {
+ guifg = { attribute = "bg", highlight = "TabLine" },
+ guibg = { attribute = "bg", highlight = "TabLine" },
+ },
+ separator_selected = {
+ guifg = { attribute = "bg", highlight = "Normal" },
+ guibg = { attribute = "bg", highlight = "Normal" },
+ },
+ -- separator_visible = {
+ -- guifg = {attribute='bg',highlight='TabLine'},
+ -- guibg = {attribute='bg',highlight='TabLine'}
+ -- },
+ indicator_selected = {
+ guifg = { attribute = "fg", highlight = "LspDiagnosticsDefaultHint" },
+ guibg = { attribute = "bg", highlight = "Normal" },
+ },
+ },
+}
diff --git a/lua/user/keymaps.lua b/lua/user/keymaps.lua
index be9bb45..48aa005 100644
--- a/lua/user/keymaps.lua
+++ b/lua/user/keymaps.lua
@@ -25,6 +25,13 @@ keymap("n", "<C-j>", "<C-w>j", opts)
keymap("n", "<C-k>", "<C-w>k", opts)
keymap("n", "<C-l>", "<C-w>l", opts)
+-- Navigate buffers
+keymap("n", "<Tab>", ":bnext<CR>", opts)
+keymap("n", "<S-Tab>", ":bprevious<CR>", opts)
+
+-- NvimTree
+keymap("n", "e", ":NvimTreeToggle<CR>", opts)
+
-- Resize with arrows
keymap("n", "<C-Up>", ":resize -2<CR>", opts)
keymap("n", "<C-Down>", ":resize +2<CR>", opts)
@@ -35,10 +42,6 @@ keymap("n", "<C-Right>", ":vertical resize +2<CR>", opts)
keymap("n", "<S-l>", ":bnext<CR>", opts)
keymap("n", "<S-h>", ":bprevious<CR>", opts)
--- Move text up and down
-keymap("n", "<A-j>", "<Esc>:m .+1<CR>==gi", opts)
-keymap("n", "<A-k>", "<Esc>:m .-2<CR>==gi", opts)
-
-- Insert --
-- Press jk fast to enter
-- keymap("i", "jk", "<ESC>", opts)
@@ -49,8 +52,8 @@ keymap("v", "<", "<gv", opts)
keymap("v", ">", ">gv", opts)
-- Move text up and down
-keymap("v", "<A-j>", ":m .+1<CR>==", opts)
-keymap("v", "<A-k>", ":m .-2<CR>==", opts)
+keymap("v", "<S-j>", "<Esc>:m .+1<CR>==gi", opts)
+keymap("v", "<S-k>", "<Esc>:m .-2<CR>==gi", opts)
keymap("v", "p", '"_dP', opts)
-- Visual Block --
diff --git a/lua/user/lsp/settings/ccls.lua b/lua/user/lsp/ccls.lua
index f182d8a..9127e5b 100644
--- a/lua/user/lsp/settings/ccls.lua
+++ b/lua/user/lsp/ccls.lua
@@ -14,7 +14,10 @@ end
lspconfig.ccls.setup {
- on_attach = on_attach,
+
+ on_attach = require("user.lsp.handlers").on_attach,
+ capabilities = require("user.lsp.handlers").capabilities,
+
flags = {
debounce_text_changes = 150,
};
diff --git a/lua/user/lsp/init.lua b/lua/user/lsp/init.lua
index c218647..744c4ec 100644
--- a/lua/user/lsp/init.lua
+++ b/lua/user/lsp/init.lua
@@ -6,4 +6,4 @@ end
require "user.lsp.lsp-installer"
require("user.lsp.handlers").setup()
-require "user.lsp.settings.ccls"
+require "user.lsp.ccls"
diff --git a/lua/user/nvim-tree.lua b/lua/user/nvim-tree.lua
new file mode 100644
index 0000000..abcdb49
--- /dev/null
+++ b/lua/user/nvim-tree.lua
@@ -0,0 +1,112 @@
+-- following options are the default
+-- each of these are documented in `:help nvim-tree.OPTION_NAME`
+vim.g.nvim_tree_icons = {
+ default = "",
+ symlink = "",
+ git = {
+ unstaged = "",
+ staged = "S",
+ unmerged = "",
+ renamed = "➜",
+ deleted = "",
+ untracked = "U",
+ ignored = "◌",
+ },
+ folder = {
+ default = "",
+ open = "",
+ empty = "",
+ empty_open = "",
+ symlink = "",
+ },
+}
+
+local status_ok, nvim_tree = pcall(require, "nvim-tree")
+if not status_ok then
+ return
+end
+
+local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config")
+if not config_status_ok then
+ return
+end
+
+local tree_cb = nvim_tree_config.nvim_tree_callback
+
+nvim_tree.setup {
+ disable_netrw = true,
+ hijack_netrw = true,
+ open_on_setup = false,
+ ignore_ft_on_setup = {
+ "startify",
+ "dashboard",
+ "alpha",
+ },
+ auto_close = true,
+ open_on_tab = false,
+ hijack_cursor = false,
+ update_cwd = true,
+ update_to_buf_dir = {
+ enable = true,
+ auto_open = true,
+ },
+ diagnostics = {
+ enable = true,
+ icons = {
+ hint = "",
+ info = "",
+ warning = "",
+ error = "",
+ },
+ },
+ update_focused_file = {
+ enable = true,
+ update_cwd = true,
+ ignore_list = {},
+ },
+ system_open = {
+ cmd = nil,
+ args = {},
+ },
+ filters = {
+ dotfiles = false,
+ custom = {},
+ },
+ git = {
+ enable = true,
+ ignore = true,
+ timeout = 500,
+ },
+ view = {
+ width = 30,
+ height = 30,
+ hide_root_folder = false,
+ side = "left",
+ auto_resize = true,
+ mappings = {
+ custom_only = false,
+ list = {
+ { key = { "l", "<CR>", "o" }, cb = tree_cb "edit" },
+ { key = "h", cb = tree_cb "close_node" },
+ { key = "v", cb = tree_cb "vsplit" },
+ },
+ },
+ number = false,
+ relativenumber = false,
+ },
+ trash = {
+ cmd = "trash",
+ require_confirm = true,
+ },
+ quit_on_open = 0,
+ git_hl = 1,
+ disable_window_picker = 0,
+ root_folder_modifier = ":t",
+ show_icons = {
+ git = 1,
+ folders = 1,
+ files = 1,
+ folder_arrows = 1,
+ tree_width = 30,
+ },
+}