diff --git a/.config/nvim/lua/lazyvim/config/autocmd.lua b/.config/nvim/lua/lazyvim/config/autocmd.lua index f8eadaf..d1ed725 100644 --- a/.config/nvim/lua/lazyvim/config/autocmd.lua +++ b/.config/nvim/lua/lazyvim/config/autocmd.lua @@ -40,41 +40,41 @@ vim.api.nvim_create_autocmd({ "VimEnter" }, { -- go to last loc when opening a buffer vim.api.nvim_create_autocmd("BufReadPost", { - callback = function() - local mark = vim.api.nvim_buf_get_mark(0, '"') - local lcount = vim.api.nvim_buf_line_count(0) - if mark[1] > 0 and mark[1] <= lcount then - pcall(vim.api.nvim_win_set_cursor, 0, mark) - end - end, + callback = function() + local mark = vim.api.nvim_buf_get_mark(0, '"') + local lcount = vim.api.nvim_buf_line_count(0) + if mark[1] > 0 and mark[1] <= lcount then + pcall(vim.api.nvim_win_set_cursor, 0, mark) + end + end, }) -- close some filetypes with vim.api.nvim_create_autocmd("FileType", { - pattern = { - "qf", - "help", - "man", - "notify", - "lspinfo", - "spectre_panel", - "startuptime", - "tsplayground", - "PlenaryTestPopup", - }, - callback = function(event) - vim.bo[event.buf].buflisted = false - vim.keymap.set("n", "q", "close", { buffer = event.buf, silent = true }) - end, + pattern = { + "qf", + "help", + "man", + "notify", + "lspinfo", + "spectre_panel", + "startuptime", + "tsplayground", + "PlenaryTestPopup", + }, + callback = function(event) + vim.bo[event.buf].buflisted = false + vim.keymap.set("n", "q", "close", { buffer = event.buf, silent = true }) + end, }) -- add spellcheck and wrapping to some file types vim.api.nvim_create_autocmd("FileType", { - pattern = { "gitcommit", "markdown" }, - callback = function() - vim.opt_local.wrap = true - vim.opt_local.spell = true - end, + pattern = { "gitcommit", "markdown" }, + callback = function() + vim.opt_local.wrap = true + vim.opt_local.spell = true + end, }) -- Prevent auto comment on next line @@ -84,16 +84,18 @@ vim.cmd([[autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatop vim.cmd([[autocmd BufRead,BufNewFile *.tex set filetype=tex]]) -- Trim whitespace from files on save -vim.cmd [[ +vim.cmd([[ autocmd BufWritePre * let currPos = getpos(".") autocmd BufWritePre * %s/\s\+$//e autocmd BufWritePre * %s/\n\+\%$//e autocmd BufWritePre *.[ch] %s/\%$/\r/e autocmd BufWritePre * cal cursor(currPos[1], currPos[2]) -]] +]]) -- Recompile and restart Xmonad on save of config file for Xmonad or Xmobar -vim.cmd([[autocmd BufWritePost ~/.xmonad/xmonad.hs,~/.config/xmobar/xmobar-main.hs,~/.config/xmobar/xmobar-sub.hs,~/.config/xmobar/xmobar-single.hs !xmonad --recompile && xmonad --restart]]) +vim.cmd( + [[autocmd BufWritePost ~/.xmonad/xmonad.hs,~/.config/xmobar/xmobar-main.hs,~/.config/xmobar/xmobar-sub.hs,~/.config/xmobar/xmobar-single.hs !xmonad --recompile && xmonad --restart]] +) -- Run custom textclear command when exiting a .tex file (cleanup files) vim.cmd([[autocmd VimLeave *.tex !texclear %]]) diff --git a/.config/nvim/lua/lazyvim/plugins/cmp.lua b/.config/nvim/lua/lazyvim/plugins/cmp.lua index 3b11966..72b3d87 100644 --- a/.config/nvim/lua/lazyvim/plugins/cmp.lua +++ b/.config/nvim/lua/lazyvim/plugins/cmp.lua @@ -26,22 +26,8 @@ return { [""] = cmp.mapping.complete(), [""] = cmp.mapping.abort(), [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - end - end, { - "i", - "s", - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - end - end, { - "i", - "s", - }), + [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), }), sources = cmp.config.sources({ { name = "nvim_lsp" }, diff --git a/.config/nvim/lua/lazyvim/plugins/lsp/init.lua b/.config/nvim/lua/lazyvim/plugins/lsp/init.lua index 845ccf2..97d969a 100644 --- a/.config/nvim/lua/lazyvim/plugins/lsp/init.lua +++ b/.config/nvim/lua/lazyvim/plugins/lsp/init.lua @@ -21,7 +21,7 @@ return { }, servers = { jsonls = {}, - lua_ls = { + sumneko_lua = { settings = { Lua = { workspace = { @@ -33,15 +33,6 @@ return { }, }, }, - -- arduino_language_server = { - -- cmd = { - -- "arduino-language-server", - -- "-cli-config", - -- "/home/solomon/.arduino15/arduino-cli.yaml", - -- "-fqbn", - -- "arduino:avr:uno", - -- }, - -- }, }, setup = { -- additional setup can be added here. @@ -84,14 +75,6 @@ return { require("lspconfig")[server].setup(server_opts) end - -- temp fix for lspconfig rename - -- https://github.com/neovim/nvim-lspconfig/pull/2439 - local mappings = require("mason-lspconfig.mappings.server") - if not mappings.lspconfig_to_package.lua_ls then - mappings.lspconfig_to_package.lua_ls = "lua-language-server" - mappings.package_to_lspconfig["lua-language-server"] = "lua_ls" - end - local mlsp = require("mason-lspconfig") local available = mlsp.get_available_servers() diff --git a/.config/nvim/lua/lazyvim/plugins/nvim-tree.lua b/.config/nvim/lua/lazyvim/plugins/nvim-tree.lua index 4a7b507..688980e 100644 --- a/.config/nvim/lua/lazyvim/plugins/nvim-tree.lua +++ b/.config/nvim/lua/lazyvim/plugins/nvim-tree.lua @@ -4,10 +4,24 @@ return { cmd = "NvimTreeToggle", config = function() local nvim_tree = require("nvim-tree") - local nvim_tree_config = require("nvim-tree.config") local icons = require("lazyvim.config.icons") - local tree_cb = nvim_tree_config.nvim_tree_callback + local function edit_or_open() + -- open as vsplit on current node + local action = "edit" + local node = lib.get_node_at_cursor() + + -- Just copy what's done normally with vsplit + if node.link_to and not node.nodes then + require("nvim-tree.actions.node.open-file").fn(action, node.link_to) + view.close() -- Close the tree if file was opened + elseif node.nodes ~= nil then + lib.expand_or_collapse(node) + else + require("nvim-tree.actions.node.open-file").fn(action, node.absolute_path) + view.close() -- Close the tree if file was opened + end + end nvim_tree.setup({ hijack_directories = { @@ -95,16 +109,15 @@ return { width = 30, hide_root_folder = false, side = "left", + number = false, + relativenumber = false, mappings = { custom_only = false, list = { - { key = { "l", "", "o" }, cb = tree_cb("edit") }, - { key = "h", cb = tree_cb("close_node") }, - { key = "v", cb = tree_cb("vsplit") }, + { key = "l", action = "edit", action_cb = edit_or_open }, + { key = "h", action = "close_node" }, }, }, - number = false, - relativenumber = false, }, actions = { open_file = {