From 4a8e5bc3fa5071eef0e900debeab27acff32d9f5 Mon Sep 17 00:00:00 2001 From: _N0x Date: Wed, 30 Oct 2024 23:24:26 +0100 Subject: [PATCH] Nvim chaos...............: --- archive/nvim_old/.config/nvim/init.lua | 13 + .../.config/nvim/lua/user/bufferline.lua | 0 .../nvim_old}/.config/nvim/lua/user/cmp.lua | 8 +- .../.config/nvim/lua/user/colorscheme.lua | 0 .../.config/nvim/lua/user/gitsigns.lua | 0 .../.config/nvim/lua/user/keymaps.lua | 0 .../.config/nvim/lua/user/lsp/handlers.lua | 2 +- .../.config/nvim/lua/user/lsp/init.lua | 4 +- .../.config/nvim/lua/user/lsp/mason.lua | 0 .../.config/nvim/lua/user/lsp/null-ls.lua | 1 - .../nvim/lua/user/lsp/settings/clang-format | 0 .../nvim/lua/user/lsp/settings/clangd.lua | 0 .../nvim/lua/user/lsp/settings/jsonls.lua | 0 .../lua/user/lsp/settings/sumneko_lua.lua | 0 .../.config/nvim/lua/user/nvim-tree.lua | 0 .../.config/nvim/lua/user/options.lua | 25 ++ .../.config/nvim/lua/user/plugins.lua | 0 .../.config/nvim/lua/user/rust-tools.lua | 0 .../.config/nvim/lua/user/statusline.lua | 0 .../.config/nvim/lua/user/telescope.lua | 0 .../.config/nvim/lua/user/treesitter.lua | 17 +- nvim/.config/nvim/init.lua | 270 +++++++++++++++++- nvim/.config/nvim/lua/bufferline.lua | 81 ++++++ nvim/.config/nvim/lua/keymap.lua | 99 +++++++ nvim/.config/nvim/lua/options.lua | 71 +++++ nvim/.config/nvim/lua/plugins.lua | 94 ++++++ nvim/.config/nvim/lua/vars.lua | 0 27 files changed, 660 insertions(+), 25 deletions(-) create mode 100644 archive/nvim_old/.config/nvim/init.lua rename {nvim => archive/nvim_old}/.config/nvim/lua/user/bufferline.lua (100%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/cmp.lua (95%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/colorscheme.lua (100%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/gitsigns.lua (100%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/keymaps.lua (100%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/lsp/handlers.lua (100%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/lsp/init.lua (99%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/lsp/mason.lua (100%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/lsp/null-ls.lua (94%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/lsp/settings/clang-format (100%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/lsp/settings/clangd.lua (100%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/lsp/settings/jsonls.lua (100%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/lsp/settings/sumneko_lua.lua (100%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/nvim-tree.lua (100%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/options.lua (74%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/plugins.lua (100%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/rust-tools.lua (100%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/statusline.lua (100%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/telescope.lua (100%) rename {nvim => archive/nvim_old}/.config/nvim/lua/user/treesitter.lua (67%) create mode 100644 nvim/.config/nvim/lua/bufferline.lua create mode 100644 nvim/.config/nvim/lua/keymap.lua create mode 100644 nvim/.config/nvim/lua/options.lua create mode 100644 nvim/.config/nvim/lua/plugins.lua create mode 100644 nvim/.config/nvim/lua/vars.lua diff --git a/archive/nvim_old/.config/nvim/init.lua b/archive/nvim_old/.config/nvim/init.lua new file mode 100644 index 0000000..5a4fad4 --- /dev/null +++ b/archive/nvim_old/.config/nvim/init.lua @@ -0,0 +1,13 @@ +require "user.options" +require "user.keymaps" +require "user.plugins" +require "user.colorscheme" +require "user.cmp" +require "user.lsp" +require "user.telescope" +require "user.treesitter" +require "user.nvim-tree" +require "user.bufferline" +require "user.statusline" +require "user.gitsigns" +require "user.rust-tools" diff --git a/nvim/.config/nvim/lua/user/bufferline.lua b/archive/nvim_old/.config/nvim/lua/user/bufferline.lua similarity index 100% rename from nvim/.config/nvim/lua/user/bufferline.lua rename to archive/nvim_old/.config/nvim/lua/user/bufferline.lua diff --git a/nvim/.config/nvim/lua/user/cmp.lua b/archive/nvim_old/.config/nvim/lua/user/cmp.lua similarity index 95% rename from nvim/.config/nvim/lua/user/cmp.lua rename to archive/nvim_old/.config/nvim/lua/user/cmp.lua index 5c96856..8acea52 100644 --- a/nvim/.config/nvim/lua/user/cmp.lua +++ b/archive/nvim_old/.config/nvim/lua/user/cmp.lua @@ -46,9 +46,15 @@ local kind_icons = { -- find more here: https://www.nerdfonts.com/cheat-sheet cmp.setup { + --snippet = { + -- expand = function(args) + -- luasnip.lsp_expand(args.body) -- For `luasnip` users. + -- end, + --}, + snippet = { expand = function(args) - luasnip.lsp_expand(args.body) -- For `luasnip` users. + vim.fn["vsnip#anonymous"](args.body) end, }, mapping = { diff --git a/nvim/.config/nvim/lua/user/colorscheme.lua b/archive/nvim_old/.config/nvim/lua/user/colorscheme.lua similarity index 100% rename from nvim/.config/nvim/lua/user/colorscheme.lua rename to archive/nvim_old/.config/nvim/lua/user/colorscheme.lua diff --git a/nvim/.config/nvim/lua/user/gitsigns.lua b/archive/nvim_old/.config/nvim/lua/user/gitsigns.lua similarity index 100% rename from nvim/.config/nvim/lua/user/gitsigns.lua rename to archive/nvim_old/.config/nvim/lua/user/gitsigns.lua diff --git a/nvim/.config/nvim/lua/user/keymaps.lua b/archive/nvim_old/.config/nvim/lua/user/keymaps.lua similarity index 100% rename from nvim/.config/nvim/lua/user/keymaps.lua rename to archive/nvim_old/.config/nvim/lua/user/keymaps.lua diff --git a/nvim/.config/nvim/lua/user/lsp/handlers.lua b/archive/nvim_old/.config/nvim/lua/user/lsp/handlers.lua similarity index 100% rename from nvim/.config/nvim/lua/user/lsp/handlers.lua rename to archive/nvim_old/.config/nvim/lua/user/lsp/handlers.lua index 08cf9bf..5c7db9b 100644 --- a/nvim/.config/nvim/lua/user/lsp/handlers.lua +++ b/archive/nvim_old/.config/nvim/lua/user/lsp/handlers.lua @@ -61,6 +61,7 @@ local function lsp_highlight_document(client) end local function lsp_keymaps(bufnr) + vim.cmd [[ command! Format execute 'lua vim.lsp.buf.format()' ]] local opts = { noremap = true, silent = true } vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "lua vim.lsp.buf.declaration()", opts) vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "lua vim.lsp.buf.definition()", opts) @@ -81,7 +82,6 @@ local function lsp_keymaps(bufnr) -- for german keyboard ... vim.api.nvim_buf_set_keymap(bufnr, "n", "*d", 'lua vim.diagnostic.goto_next({ border = "rounded" })', opts) vim.api.nvim_buf_set_keymap(bufnr, "n", "q", "lua vim.diagnostic.setloclist()", opts) - vim.cmd [[ command! Format execute 'lua vim.lsp.buf.format()' ]] end M.on_attach = function(client, bufnr) diff --git a/nvim/.config/nvim/lua/user/lsp/init.lua b/archive/nvim_old/.config/nvim/lua/user/lsp/init.lua similarity index 99% rename from nvim/.config/nvim/lua/user/lsp/init.lua rename to archive/nvim_old/.config/nvim/lua/user/lsp/init.lua index c493e7d..bea8ab2 100644 --- a/nvim/.config/nvim/lua/user/lsp/init.lua +++ b/archive/nvim_old/.config/nvim/lua/user/lsp/init.lua @@ -7,8 +7,6 @@ require "user.lsp.mason" require("user.lsp.handlers").setup() require "user.lsp.null-ls" - - -- LSP Diagnostics Options Setup local sign = function(opts) vim.fn.sign_define(opts.name, { @@ -41,4 +39,4 @@ vim.cmd([[ set signcolumn=yes autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) ]]) - + diff --git a/nvim/.config/nvim/lua/user/lsp/mason.lua b/archive/nvim_old/.config/nvim/lua/user/lsp/mason.lua similarity index 100% rename from nvim/.config/nvim/lua/user/lsp/mason.lua rename to archive/nvim_old/.config/nvim/lua/user/lsp/mason.lua diff --git a/nvim/.config/nvim/lua/user/lsp/null-ls.lua b/archive/nvim_old/.config/nvim/lua/user/lsp/null-ls.lua similarity index 94% rename from nvim/.config/nvim/lua/user/lsp/null-ls.lua rename to archive/nvim_old/.config/nvim/lua/user/lsp/null-ls.lua index 4cf358c..9e61180 100644 --- a/nvim/.config/nvim/lua/user/lsp/null-ls.lua +++ b/archive/nvim_old/.config/nvim/lua/user/lsp/null-ls.lua @@ -16,6 +16,5 @@ null_ls.setup({ extra_filetypes = {"inl"}, extra_args = {"-style=file:~/.config/nvim/lua/user/lsp/settings/clang-format"}, }), - null_ls.builtins.formatting.rustfmt, }, }) diff --git a/nvim/.config/nvim/lua/user/lsp/settings/clang-format b/archive/nvim_old/.config/nvim/lua/user/lsp/settings/clang-format similarity index 100% rename from nvim/.config/nvim/lua/user/lsp/settings/clang-format rename to archive/nvim_old/.config/nvim/lua/user/lsp/settings/clang-format diff --git a/nvim/.config/nvim/lua/user/lsp/settings/clangd.lua b/archive/nvim_old/.config/nvim/lua/user/lsp/settings/clangd.lua similarity index 100% rename from nvim/.config/nvim/lua/user/lsp/settings/clangd.lua rename to archive/nvim_old/.config/nvim/lua/user/lsp/settings/clangd.lua diff --git a/nvim/.config/nvim/lua/user/lsp/settings/jsonls.lua b/archive/nvim_old/.config/nvim/lua/user/lsp/settings/jsonls.lua similarity index 100% rename from nvim/.config/nvim/lua/user/lsp/settings/jsonls.lua rename to archive/nvim_old/.config/nvim/lua/user/lsp/settings/jsonls.lua diff --git a/nvim/.config/nvim/lua/user/lsp/settings/sumneko_lua.lua b/archive/nvim_old/.config/nvim/lua/user/lsp/settings/sumneko_lua.lua similarity index 100% rename from nvim/.config/nvim/lua/user/lsp/settings/sumneko_lua.lua rename to archive/nvim_old/.config/nvim/lua/user/lsp/settings/sumneko_lua.lua diff --git a/nvim/.config/nvim/lua/user/nvim-tree.lua b/archive/nvim_old/.config/nvim/lua/user/nvim-tree.lua similarity index 100% rename from nvim/.config/nvim/lua/user/nvim-tree.lua rename to archive/nvim_old/.config/nvim/lua/user/nvim-tree.lua diff --git a/nvim/.config/nvim/lua/user/options.lua b/archive/nvim_old/.config/nvim/lua/user/options.lua similarity index 74% rename from nvim/.config/nvim/lua/user/options.lua rename to archive/nvim_old/.config/nvim/lua/user/options.lua index e4d9b91..fa414fe 100644 --- a/nvim/.config/nvim/lua/user/options.lua +++ b/archive/nvim_old/.config/nvim/lua/user/options.lua @@ -51,3 +51,28 @@ vim.cmd "set listchars=tab:\\ \\ ,space:·" --vim.cmd "set term=screen-256color" vim.g.vimwiki_list = {{path = '~/Documents/vimwiki', syntax = 'markdown', ext = '.md'}} vim.g.nord_disable_background = true + +--Set completeopt to have a better completion experience +-- :help completeopt +-- menuone: popup even when there's only one match +-- noinsert: Do not insert text until a selection is made +-- noselect: Do not select, force to select one from the menu +-- shortness: avoid showing extra messages when using completion +-- updatetime: set updatetime for CursorHold +vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'} +vim.opt.shortmess = vim.opt.shortmess + { c = true} +vim.api.nvim_set_option('updatetime', 300) + +-- Fixed column for diagnostics to appear +-- Show autodiagnostic popup on cursor hover_range +-- Goto previous / next diagnostic warning / error +-- Show inlay_hints more frequently +vim.cmd([[ +set signcolumn=yes +autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) +]]) + + +-- Treesitter folding +vim.wo.foldmethod = 'expr' +vim.wo.foldexpr = 'nvim_treesitter#foldexpr()' diff --git a/nvim/.config/nvim/lua/user/plugins.lua b/archive/nvim_old/.config/nvim/lua/user/plugins.lua similarity index 100% rename from nvim/.config/nvim/lua/user/plugins.lua rename to archive/nvim_old/.config/nvim/lua/user/plugins.lua diff --git a/nvim/.config/nvim/lua/user/rust-tools.lua b/archive/nvim_old/.config/nvim/lua/user/rust-tools.lua similarity index 100% rename from nvim/.config/nvim/lua/user/rust-tools.lua rename to archive/nvim_old/.config/nvim/lua/user/rust-tools.lua diff --git a/nvim/.config/nvim/lua/user/statusline.lua b/archive/nvim_old/.config/nvim/lua/user/statusline.lua similarity index 100% rename from nvim/.config/nvim/lua/user/statusline.lua rename to archive/nvim_old/.config/nvim/lua/user/statusline.lua diff --git a/nvim/.config/nvim/lua/user/telescope.lua b/archive/nvim_old/.config/nvim/lua/user/telescope.lua similarity index 100% rename from nvim/.config/nvim/lua/user/telescope.lua rename to archive/nvim_old/.config/nvim/lua/user/telescope.lua diff --git a/nvim/.config/nvim/lua/user/treesitter.lua b/archive/nvim_old/.config/nvim/lua/user/treesitter.lua similarity index 67% rename from nvim/.config/nvim/lua/user/treesitter.lua rename to archive/nvim_old/.config/nvim/lua/user/treesitter.lua index 3c24109..e5672c4 100644 --- a/nvim/.config/nvim/lua/user/treesitter.lua +++ b/archive/nvim_old/.config/nvim/lua/user/treesitter.lua @@ -6,13 +6,18 @@ end configs.setup({ ensure_installed = { "bash", "c", "cpp", "javascript", "json", "lua", "python", "typescript", "tsx", "css", "rust", "java", "yaml", "markdown", "markdown_inline" }, -- one of "all" or a list of languages ignore_install = { "phpdoc" }, -- List of parsers to ignore installing - highlight = { - enable = true, -- false will disable the whole extension - disable = { "css" }, -- list of language that will be disabled - }, + highlight = { + enable = true, + additional_vim_regex_highlighting=false, + }, + ident = { enable = true }, + rainbow = { + enable = true, + extended_mode = true, + max_file_lines = nil, + }, autopairs = { enable = true, - }, - indent = { enable = true, disable = { "python", "css" } }, + } }) diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 5a4fad4..a3f8fb6 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -1,13 +1,257 @@ -require "user.options" -require "user.keymaps" -require "user.plugins" -require "user.colorscheme" -require "user.cmp" -require "user.lsp" -require "user.telescope" -require "user.treesitter" -require "user.nvim-tree" -require "user.bufferline" -require "user.statusline" -require "user.gitsigns" -require "user.rust-tools" +require "keymap" +require "options" +require "plugins" +require "vars" +--require "bufferline" + +-- Color Theme +vim.cmd [[ +try + colorscheme nord +endtry +]] + +require("bufferline").setup() + +-- Mason Setup +require("mason").setup({ + ui = { + icons = { + package_installed = "", + package_pending = "", + package_uninstalled = "", + }, + } +}) +require("mason-lspconfig").setup() + +-- Rust Tools Setup +local rt = require("rust-tools") +rt.setup({ + server = { + on_attach = function(_, bufnr) + -- Hover actions + vim.keymap.set("n", "", rt.hover_actions.hover_actions, { buffer = bufnr }) + -- Code action groups + vim.keymap.set("n", "a", rt.code_action_group.code_action_group, { buffer = bufnr }) + end, + }, +}) + +-- LSP Diagnostics Options Setup +local sign = function(opts) + vim.fn.sign_define(opts.name, { + texthl = opts.name, + text = opts.text, + numhl = '' + }) +end + +sign({name = 'DiagnosticSignError', text = ''}) +sign({name = 'DiagnosticSignWarn', text = ''}) +sign({name = 'DiagnosticSignHint', text = ''}) +sign({name = 'DiagnosticSignInfo', text = ''}) + +vim.diagnostic.config({ + virtual_text = false, + signs = true, + update_in_insert = true, + underline = true, + severity_sort = false, + float = { + border = 'rounded', + source = 'always', + header = '', prefix = '', + }, +}) + +vim.cmd([[ +set signcolumn=yes +autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) +]]) + +-- Completion Plugin Setup +local cmp = require'cmp' +cmp.setup({ + -- Enable LSP snippets + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + mapping = { + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + -- Add tab support + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }) + }, + -- Installed sources: + sources = { + { name = 'path' }, -- file paths + { name = 'nvim_lsp', keyword_length = 3 }, -- from language server + { name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized + { name = 'nvim_lua', keyword_length = 2}, -- complete neovim's Lua runtime API such vim.lsp.* + { name = 'buffer', keyword_length = 2 }, -- source current buffer + { name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip + { name = 'calc'}, -- source for math calculation + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + formatting = { + fields = {'menu', 'abbr', 'kind'}, + format = function(entry, item) + local menu_icon ={ + nvim_lsp = 'λ', + vsnip = '⋗', + buffer = 'Ω', + path = '🖫', + } + item.menu = menu_icon[entry.source.name] + return item + end, + }, +}) + + + +-- Treesitter Plugin Setup +require('nvim-treesitter.configs').setup { + ensure_installed = { "bash", "c", "cpp", "javascript", "json", "lua", "python", "typescript", "tsx", "css", "rust", "java", "yaml", "markdown", "markdown_inline" }, + auto_install = true, + highlight = { + enable = true, + additional_vim_regex_highlighting=false, + }, + ident = { enable = true }, + rainbow = { + enable = true, + extended_mode = true, + max_file_lines = nil, + } +} + +-- nvim-tree Setup +-- following options are the default +-- each of these are documented in `:help nvim-tree.OPTION_NAME` + +local nvimtree = require("nvim-tree") + +nvimtree.setup { + on_attach = function(bufnr) + local api = require("nvim-tree.api") + + local function opts(desc) + return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + api.config.mappings.default_on_attach(bufnr) + vim.keymap.set("n", "", api.node.open.edit, opts("Open")) + end, + renderer = { + icons = { + webdev_colors = true, + git_placement = "before", + padding = " ", + symlink_arrow = " ➛ ", + show = { + file = true, + folder = true, + folder_arrow = true, + git = true, + }, + glyphs = { + default = "", + symlink = "", + git = { + unstaged = "", + staged = "S", + unmerged = "", + renamed = "➜", + deleted = "", + untracked = "U", + ignored = "◌", + }, + folder = { + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + }, + }, + }, + highlight_git = true, + root_folder_modifier = ":t", + }, + hijack_directories = { + enable = true, + auto_open = true, + }, + disable_netrw = true, + hijack_netrw = true, + hijack_cursor = false, + update_cwd = 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, + side = "left", + float = { + quit_on_focus_loss = true, + }, + }, + trash = { + cmd = "trash", + require_confirm = true, + }, + actions = { + open_file = { + resize_window = true, + quit_on_open = false, + window_picker = { + enable = false, + }, + }, + }, +} + +-- Statusline +require('lualine').setup { + options = { theme = 'nord' } +} + diff --git a/nvim/.config/nvim/lua/bufferline.lua b/nvim/.config/nvim/lua/bufferline.lua new file mode 100644 index 0000000..7f738f5 --- /dev/null +++ b/nvim/.config/nvim/lua/bufferline.lua @@ -0,0 +1,81 @@ +local status_ok, bufferline = pcall(require, "bufferline") +if not status_ok then + return +end + +bufferline.setup { + options = { + mode = "buffers", -- set to "tabs" to only show tabpages instead + style_preset = bufferline.style_preset.default, -- or bufferline.style_preset.minimal, + themable = true, -- allows highlight groups to be overriden i.e. sets highlights as default + numbers = "none", -- | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string, + close_command = "bdelete! %d", -- can be a string | function, | false see "Mouse actions" + right_mouse_command = "bdelete! %d", -- can be a string | function | false, see "Mouse actions" + left_mouse_command = "buffer %d", -- can be a string | function, | false see "Mouse actions" + middle_mouse_command = nil, -- can be a string | function, | false see "Mouse actions" + indicator = { + icon = '▎', -- this should be omitted if indicator style is not 'icon' + style = 'icon', --| 'underline' | 'none', + }, + buffer_close_icon = '󰅖', + modified_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. + max_name_length = 18, + max_prefix_length = 15, -- prefix used when a buffer is de-duplicated + truncate_names = true, -- whether or not tab names should be truncated + tab_size = 18, + diagnostics = "nvim_lsp", + diagnostics_update_in_insert = false, -- only applies to coc + diagnostics_update_on_event = true, -- use nvim's diagnostic handler + -- The diagnostics indicator can be set to nil to keep the buffer name highlight but delete the highlighting + offsets = { + { + filetype = "NvimTree", + text = "File Explorer",-- | function , + text_align = "left",-- | "center" | "right" + separator = true + } + }, + color_icons = true, -- whether or not to add the filetype icon highlights + get_element_icon = function(element) + -- element consists of {filetype: string, path: string, extension: string, directory: string} + -- This can be used to change how bufferline fetches the icon + -- for an element e.g. a buffer or a tab. + -- e.g. + local icon, hl = require('nvim-web-devicons').get_icon_by_filetype(element.filetype, { default = false }) + return icon, hl + -- or + --local custom_map = {my_thing_ft: {icon = "my_thing_icon", hl}} + --return custom_map[element.filetype] + end, + show_buffer_icons = true , -- disable filetype icons for buffers + show_buffer_close_icons = true , + show_close_icon = true, + show_tab_indicators = true , + show_duplicate_prefix = true , -- whether to show duplicate buffer prefix + duplicates_across_groups = true, -- whether to consider duplicate paths in different groups as duplicates + persist_buffer_sort = true, -- whether or not custom sorted buffers should persist + move_wraps_at_ends = false, -- whether or not the move command "wraps" at the first or last position + -- can also be a table containing 2 custom separators + -- [focused and unfocused]. eg: { '|', '|' } + separator_style = "thin", --| "slope" | "thick" | "thin" | { 'any', 'any' }, + enforce_regular_tabs = true,--| true, + always_show_bufferline = true,-- | false, + auto_toggle_bufferline = true,-- | false, + hover = { + enabled = true, + delay = 200, + reveal = {'close'} + }, + sort_by = 'insert_after_current', + pick = { + alphabet = "abcdefghijklmopqrstuvwxyzABCDEFGHIJKLMOPQRSTUVWXYZ1234567890", + }, + } +} diff --git a/nvim/.config/nvim/lua/keymap.lua b/nvim/.config/nvim/lua/keymap.lua new file mode 100644 index 0000000..828f71d --- /dev/null +++ b/nvim/.config/nvim/lua/keymap.lua @@ -0,0 +1,99 @@ +local opts = { noremap = true, silent = true } + +local term_opts = { silent = true } + +-- Shorten function name +local keymap = vim.api.nvim_set_keymap + +--Remap space as leader key +keymap("", "", "", opts) +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +-- Modes +-- normal_mode = "n", +-- insert_mode = "i", +-- visual_mode = "v", +-- visual_block_mode = "x", +-- term_mode = "t", +-- command_mode = "c", + +-- Disable Arrow keys to force myself to the Vim-Way of movement -- +keymap("i", "", "", opts) +keymap("i", "", "", opts) +keymap("i", "", "", opts) +keymap("i", "", "", opts) + +keymap("n", "", "", opts) +keymap("n", "", "", opts) +keymap("n", "", "", opts) +keymap("n", "", "", opts) + +-- Remap some language specific stuff -- +keymap("n", "ü", "{", opts) +keymap("n", "", "", opts) + +keymap("n", "+", "}", opts) +keymap("n", "", "", opts) + +-- Normal -- +-- Better window navigation +keymap("n", "", "h", opts) +keymap("n", "", "j", opts) +keymap("n", "", "k", opts) +keymap("n", "", "l", opts) + +keymap("n", "e", ":NvimTreeToggle", opts) + +-- Resize with arrows +keymap("n", "", ":resize -2", opts) +keymap("n", "", ":resize +2", opts) +keymap("n", "", ":vertical resize -2", opts) +keymap("n", "", ":vertical resize +2", opts) + +-- Navigate buffers +keymap("n", "", ":bnext", opts) +keymap("n", "", ":bprevious", opts) + +-- Move text up and down +keymap("n", "", ":m .+1==gi", opts) +keymap("n", "", ":m .-2==gi", opts) + +-- Insert -- +-- Press jk fast to enter +keymap("i", "jk", "", opts) + +-- Visual -- +-- Stay in indent mode +keymap("v", "<", "", ">gv", opts) + +-- Move text up and down +keymap("v", "", ":m .+1==", opts) +keymap("v", "", ":m .-2==", opts) +keymap("v", "p", '"_dP', opts) + +-- Visual Block -- +-- Move text up and down +keymap("x", "J", ":move '>+1gv-gv", opts) +keymap("x", "K", ":move '<-2gv-gv", opts) +keymap("x", "", ":move '>+1gv-gv", opts) +keymap("x", "", ":move '<-2gv-gv", opts) + +-- Terminal -- +-- Better terminal navigation +keymap("t", "", "", term_opts) +keymap("t", "", "h", term_opts) +keymap("t", "", "j", term_opts) +keymap("t", "", "k", term_opts) +keymap("t", "", "l", term_opts) + +-- Format document -- +keymap("n", "f", "Format", opts) + +-- close buffer -- +keymap("n", "q", "Bdelete! %d", opts) + +-- toggle whitespace -- +keymap("n", "w", "set list!", opts) + diff --git a/nvim/.config/nvim/lua/options.lua b/nvim/.config/nvim/lua/options.lua new file mode 100644 index 0000000..6ca4bd7 --- /dev/null +++ b/nvim/.config/nvim/lua/options.lua @@ -0,0 +1,71 @@ +local options = { + backup = false, -- creates a backup file + clipboard = "unnamedplus", -- allows neovim to access the system clipboard + cmdheight = 2, -- more space in the neovim command line for displaying messages + conceallevel = 0, -- so that `` is visible in markdown files + fileencoding = "utf-8", -- the encoding written to a file + hlsearch = true, -- highlight all matches on previous search pattern + ignorecase = true, -- ignore case in search patterns + mouse = "a", -- allow the mouse to be used in neovim + pumheight = 10, -- pop up menu height + showmode = false, -- we don't need to see things like -- INSERT -- anymore + showtabline = 2, -- always show tabs + smartcase = true, -- smart case + smartindent = true, -- make indenting smarter again + splitbelow = true, -- force all horizontal splits to go below current window + splitright = true, -- force all vertical splits to go to the right of current window + swapfile = false, -- creates a swapfile + termguicolors = true, -- set term gui colors (most terminals support this) + timeoutlen = 1000, -- time to wait for a mapped sequence to complete (in milliseconds) + undofile = true, -- enable persistent undo + updatetime = 300, -- faster completion (4000ms default) + writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited + expandtab = true, -- convert tabs to spaces + shiftwidth = 4, -- the number of spaces inserted for each indentation + tabstop = 4, -- insert 2 spaces for a tab + cursorline = true, -- highlight the current line + number = true, -- set numbered lines + relativenumber = true, -- set relative numbered lines + numberwidth = 4, -- set number column width to 2 {default 4} + signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time + wrap = false, -- display lines as one long line + scrolloff = 8, -- is one of my fav + sidescrolloff = 8, + guifont = "monospace:h17", -- the font used in graphical neovim applications + list = true, + foldenable = false, +} + +vim.opt.shortmess:append "c" + +for k, v in pairs(options) do + vim.opt[k] = v +end + +vim.g.vimwiki_list = {{path = '~/Documents/vimwiki', syntax = 'markdown', ext = '.md'}} +vim.g.nord_disable_background = true + +--Set completeopt to have a better completion experience +-- :help completeopt +-- menuone: popup even when there's only one match +-- noinsert: Do not insert text until a selection is made +-- noselect: Do not select, force to select one from the menu +-- shortness: avoid showing extra messages when using completion +-- updatetime: set updatetime for CursorHold +vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'} +vim.opt.shortmess = vim.opt.shortmess + { c = true} +vim.api.nvim_set_option('updatetime', 300) + +-- Fixed column for diagnostics to appear +-- Show autodiagnostic popup on cursor hover_range +-- Goto previous / next diagnostic warning / error +-- Show inlay_hints more frequently +vim.cmd([[ +set signcolumn=yes +autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) +]]) + +-- Treesitter folding +vim.wo.foldmethod = 'expr' +vim.wo.foldexpr = 'nvim_treesitter#foldexpr()' + diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua new file mode 100644 index 0000000..dd5449a --- /dev/null +++ b/nvim/.config/nvim/lua/plugins.lua @@ -0,0 +1,94 @@ +local fn = vim.fn + +-- Automatically install packer +local install_path = fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim" +if fn.empty(fn.glob(install_path)) > 0 then + PACKER_BOOTSTRAP = fn.system { + "git", + "clone", + "--depth", + "1", + "https://github.com/wbthomason/packer.nvim", install_path, + } + print "Installing packer close and reopen Neovim..." + vim.cmd [[packadd packer.nvim]] +end + +-- Autocommand that reloads neovim whenever you save the plugins.lua file +vim.cmd [[ + augroup packer_user_config + autocmd! + autocmd BufWritePost plugins.lua source | PackerSync + augroup end +]] + +-- Use a protected call so we don't error out on first use +local status_ok, packer = pcall(require, "packer") +if not status_ok then + return +end + +-- Have packer use a popup window +packer.init { + display = { + open_fn = function() + return require("packer.util").float { border = "rounded" } + end, + }, +} + +-- Install your plugins here +return packer.startup(function(use) + -- My plugins here + use "wbthomason/packer.nvim" -- Have packer manage itself + + -- Colorschemes + use "shaunsingh/nord.nvim" + + -- LSP + use "neovim/nvim-lspconfig" -- enable LSP + use "williamboman/mason.nvim" -- simple to use language server installer + use "williamboman/mason-lspconfig.nvim" -- simple to use language server installer + + use 'simrat39/rust-tools.nvim' + + -- Completion framework: + use 'hrsh7th/nvim-cmp' + + -- LSP completion source: + use 'hrsh7th/cmp-nvim-lsp' + + -- Useful completion sources: + use 'hrsh7th/cmp-nvim-lua' + use 'hrsh7th/cmp-nvim-lsp-signature-help' + use 'hrsh7th/cmp-vsnip' + use 'hrsh7th/cmp-path' + use 'hrsh7th/vim-vsnip' + use "hrsh7th/cmp-cmdline" -- cmdline completions + + use 'nvim-treesitter/nvim-treesitter' + + -- lualine (bottom line) + use {'nvim-lualine/lualine.nvim', requires = { 'nvim-tree/nvim-web-devicons', opt = true} } + + -- nvim-tree + use {'kyazdani42/nvim-tree.lua', requires = 'nvim-tree/nvim-web-devicons'} + + -- Bufferline + use {'akinsho/bufferline.nvim', requires = 'nvim-tree/nvim-web-devicons'} + + -- VimWiki + use { 'vimwiki/vimwiki', branch='dev'} + + -- dicord fuckery + use 'andweeb/presence.nvim' + + -- LaTeX + --use 'lervag/vimtex' + + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if PACKER_BOOTSTRAP then + require("packer").sync() + end +end) diff --git a/nvim/.config/nvim/lua/vars.lua b/nvim/.config/nvim/lua/vars.lua new file mode 100644 index 0000000..e69de29