From 8a9f62baaf3a64d98eed94cf6efeb67cc54206b5 Mon Sep 17 00:00:00 2001 From: Solomon Laing Date: Wed, 9 Nov 2022 21:22:52 +1030 Subject: [PATCH] updates to nvim, not sure about all this yet... --- .config/lf/lfrc | 4 +- .config/nvim/init.lua | 2 +- .config/nvim/lua/user/alpha.lua | 1 - .config/nvim/lua/user/lsp/handlers.lua | 204 +++++++++++++------------ .config/nvim/lua/user/lsp/mason.lua | 4 +- .config/nvim/lua/user/noice.lua | 8 +- .config/nvim/lua/user/winbar.lua | 2 +- 7 files changed, 114 insertions(+), 111 deletions(-) diff --git a/.config/lf/lfrc b/.config/lf/lfrc index 77bcfb5..263d20d 100644 --- a/.config/lf/lfrc +++ b/.config/lf/lfrc @@ -131,8 +131,8 @@ cmd mkfile_and_edit ${{ }} cmd zk_edit ${{ - eval zk edit -i - }} + eval zk edit --interactive --sort modified- +}} cmd zk_edit_file ${{ name=$(echo "$f" | sed 's/\..*//' | sed 's/.*\///') diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index b65a553..d927d06 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -34,7 +34,7 @@ require "user.spectre" -- require "user.bufferline" -- replaced with cybu and bbye -- disabled due to "Not enough room" issue see https://github.com/neovim/neovim/issues/19464 -- and potential conflict with noice, I added it same time as updating so maybe not. --- require "user.winbar" +require "user.winbar" require "user.zk" require "user.tabout" require "user.cybu" diff --git a/.config/nvim/lua/user/alpha.lua b/.config/nvim/lua/user/alpha.lua index 88cb062..448a26e 100644 --- a/.config/nvim/lua/user/alpha.lua +++ b/.config/nvim/lua/user/alpha.lua @@ -23,7 +23,6 @@ dashboard.section.header.val = { dashboard.section.buttons.val = { button("f", icons.documents.Files .. " Find file", ":Telescope find_files "), button("e", icons.ui.NewFile .. " New file", ":ene startinsert "), - button("p", icons.git.Repo .. " Find project", ":lua require('telescope').extensions.projects.projects()"), button("r", icons.ui.History .. " Recent files", ":Telescope oldfiles "), button("t", icons.ui.List .. " Find text", ":Telescope live_grep "), button("c", icons.ui.Gear .. " Config", ":e ~/.config/nvim/init.lua "), diff --git a/.config/nvim/lua/user/lsp/handlers.lua b/.config/nvim/lua/user/lsp/handlers.lua index 8f8ecaa..d1060dd 100644 --- a/.config/nvim/lua/user/lsp/handlers.lua +++ b/.config/nvim/lua/user/lsp/handlers.lua @@ -4,145 +4,147 @@ M.capabilities = vim.lsp.protocol.make_client_capabilities() local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") if not status_cmp_ok then - print "cmp_nvim_lsp error!" - return + print("cmp_nvim_lsp error!") + return end M.capabilities.textDocument.completion.completionItem.snippetSupport = true M.capabilities = cmp_nvim_lsp.default_capabilities(M.capabilities) M.setup = function() - local icons = require "user.icons" - local signs = { - { name = "DiagnosticSignError", text = icons.diagnostics.Error }, - { name = "DiagnosticSignWarn", text = icons.diagnostics.Warning }, - { name = "DiagnosticSignHint", text = icons.diagnostics.Hint }, - { name = "DiagnosticSignInfo", text = icons.diagnostics.Information }, - } + local icons = require("user.icons") + local signs = { + { name = "DiagnosticSignError", text = icons.diagnostics.Error }, + { name = "DiagnosticSignWarn", text = icons.diagnostics.Warning }, + { name = "DiagnosticSignHint", text = icons.diagnostics.Hint }, + { name = "DiagnosticSignInfo", text = icons.diagnostics.Information }, + } - for _, sign in ipairs(signs) do - vim.fn.sign_define(sign.name, { - texthl = sign.name, text = sign.text, numhl = "" - }) - end + for _, sign in ipairs(signs) do + vim.fn.sign_define(sign.name, { + texthl = sign.name, + text = sign.text, + numhl = "", + }) + end - local config = { - -- disable virtual text - virtual_lines = false, - virtual_text = false, - -- virtual_text = { - -- -- spacing = 7, - -- -- update_in_insert = false, - -- -- severity_sort = true, - -- -- prefix = "<-", - -- prefix = " ●", - -- source = "if_many", -- Or "always" - -- -- format = function(diag) - -- -- return diag.message .. "blah" - -- -- end, - -- }, + local config = { + -- disable virtual text + virtual_lines = false, + virtual_text = false, + -- virtual_text = { + -- -- spacing = 7, + -- -- update_in_insert = false, + -- -- severity_sort = true, + -- -- prefix = "<-", + -- prefix = " ●", + -- source = "if_many", -- Or "always" + -- -- format = function(diag) + -- -- return diag.message .. "blah" + -- -- end, + -- }, - -- show signs - signs = { - active = signs, - }, - update_in_insert = true, - underline = true, - severity_sort = true, - float = { - focusable = true, - style = "minimal", - border = "rounded", - -- border = {"▄","▄","▄","█","▀","▀","▀","█"}, - source = "if_many", -- Or "always" - header = "", - prefix = "", - -- width = 40, - }, - } + -- show signs + signs = { + active = signs, + }, + update_in_insert = true, + underline = true, + severity_sort = true, + float = { + focusable = true, + style = "minimal", + border = "rounded", + -- border = {"▄","▄","▄","█","▀","▀","▀","█"}, + source = "if_many", -- Or "always" + header = "", + prefix = "", + -- width = 40, + }, + } - vim.diagnostic.config(config) + vim.diagnostic.config(config) - vim.lsp.handlers["textDocument/hover"] = - vim.lsp.with(vim.lsp.handlers.hover, { - border = "rounded", - -- width = 60, - -- height = 30, - }) + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = "rounded", + -- width = 60, + -- height = 30, + }) - vim.lsp.handlers["textDocument/signatureHelp"] = - vim.lsp.with(vim.lsp.handlers.signature_help, { - border = "rounded", - -- width = 60, - -- height = 30, - }) + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = "rounded", + -- width = 60, + -- height = 30, + }) end local function attach_navic(client, bufnr) - vim.g.navic_silence = true - local status_ok, navic = pcall(require, "nvim-navic") - if not status_ok then - print "nvim-navic error!" - return - end - navic.attach(client, bufnr) + vim.g.navic_silence = false + local status_ok, navic = pcall(require, "nvim-navic") + if not status_ok then + print"nvim-navic error!" + return + end + if client.server_capabilities.documentSymbolProvider then + navic.attach(client, bufnr) + end end local function lsp_keymaps(bufnr) - local opts = { noremap = true, silent = true } - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "Telescope lsp_definitions", opts) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "Telescope lsp_declarations", opts) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "lua vim.lsp.buf.hover()", opts) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gI", "Telescope lsp_implementations", opts) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "Telescope lsp_references", opts) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gl", "lua vim.diagnostic.open_float()", opts) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gs", "lua vim.lsp.buf.signature_help()", opts) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "", "Format", opts) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "", "lua vim.lsp.buf.code_action()", opts) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "", "lua vim.lsp.buf.signature_help()", opts) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "rn", "lua vim.lsp.buf.rename()", opts) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "ca", "lua vim.lsp.buf.code_action()", opts) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "f", "lua vim.diagnostic.open_float()", opts) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", 'lua vim.diagnostic.goto_prev({ border = "rounded" })', opts) - -- 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({ async = true })' ]] + local opts = { noremap = true, silent = true } + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "Telescope lsp_definitions", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "Telescope lsp_declarations", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "lua vim.lsp.buf.hover()", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gI", "Telescope lsp_implementations", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "Telescope lsp_references", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gl", "lua vim.diagnostic.open_float()", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gs", "lua vim.lsp.buf.signature_help()", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "", "Format", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "", "lua vim.lsp.buf.code_action()", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "", "lua vim.lsp.buf.signature_help()", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "rn", "lua vim.lsp.buf.rename()", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "ca", "lua vim.lsp.buf.code_action()", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "f", "lua vim.diagnostic.open_float()", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", 'lua vim.diagnostic.goto_prev({ border = "rounded" })', opts) + -- 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({ async = true })' ]] end M.on_attach = function(client, bufnr) - lsp_keymaps(bufnr) - attach_navic(client, bufnr) + lsp_keymaps(bufnr) + attach_navic(client, bufnr) end function M.enable_format_on_save() - vim.cmd [[ + vim.cmd([[ augroup format_on_save autocmd! autocmd BufWritePre * lua vim.lsp.buf.format({ async = false }) augroup end - ]] - vim.notify "Enabled format on save" + ]]) + vim.notify("Enabled format on save") end function M.disable_format_on_save() - M.remove_augroup "format_on_save" - vim.notify "Disabled format on save" + M.remove_augroup("format_on_save") + vim.notify("Disabled format on save") end function M.toggle_format_on_save() - if vim.fn.exists "#format_on_save#BufWritePre" == 0 then - M.enable_format_on_save() - else - M.disable_format_on_save() - end + if vim.fn.exists("#format_on_save#BufWritePre") == 0 then + M.enable_format_on_save() + else + M.disable_format_on_save() + end end function M.remove_augroup(name) - if vim.fn.exists("#" .. name) == 1 then - vim.cmd("au! " .. name) - end + if vim.fn.exists("#" .. name) == 1 then + vim.cmd("au! " .. name) + end end -vim.cmd [[ command! LspToggleAutoFormat execute 'lua require("user.lsp.handlers").toggle_format_on_save()' ]] +vim.cmd([[ command! LspToggleAutoFormat execute 'lua require("user.lsp.handlers").toggle_format_on_save()' ]]) return M diff --git a/.config/nvim/lua/user/lsp/mason.lua b/.config/nvim/lua/user/lsp/mason.lua index 2b3321c..9d085c0 100644 --- a/.config/nvim/lua/user/lsp/mason.lua +++ b/.config/nvim/lua/user/lsp/mason.lua @@ -81,7 +81,9 @@ for _, server in pairs(servers) do end if server == "sumneko_lua" then - lspconfig.sumneko_lua.setup({}) + lspconfig.sumneko_lua.setup({ + on_attach = require("user.lsp.handlers").on_attach, + }) goto continue end diff --git a/.config/nvim/lua/user/noice.lua b/.config/nvim/lua/user/noice.lua index 7201a5b..14ca1e7 100644 --- a/.config/nvim/lua/user/noice.lua +++ b/.config/nvim/lua/user/noice.lua @@ -5,7 +5,7 @@ end noice.setup({ cmdline = { - enabled = true, -- enables the Noice cmdline UI + enabled = false, -- enables the Noice cmdline UI view = "cmdline_popup", -- view for rendering the cmdline. Change to `cmdline` to get a classic cmdline at the bottom opts = {}, -- global options for the cmdline. See section on views ---@type table @@ -28,7 +28,7 @@ noice.setup({ messages = { -- NOTE: If you enable messages, then the cmdline is enabled automatically. -- This is a current Neovim limitation. - enabled = true, -- enables the Noice messages UI + enabled = false, -- enables the Noice messages UI view = "notify", -- default view for messages view_error = "notify", -- view for errors view_warn = "notify", -- view for warnings @@ -109,9 +109,9 @@ noice.setup({ -- override the default lsp markdown formatter with Noice ["vim.lsp.util.convert_input_to_markdown_lines"] = true, -- override the lsp markdown formatter with Noice - ["vim.lsp.util.stylize_markdown"] = false, + ["vim.lsp.util.stylize_markdown"] = true, -- override cmp documentation with Noice (needs the other options to work) - ["cmp.entry.get_documentation"] = false, + ["cmp.entry.get_documentation"] = true, }, hover = { enabled = true, diff --git a/.config/nvim/lua/user/winbar.lua b/.config/nvim/lua/user/winbar.lua index e4decde..eda8bfd 100644 --- a/.config/nvim/lua/user/winbar.lua +++ b/.config/nvim/lua/user/winbar.lua @@ -6,7 +6,7 @@ end winbar.setup({ enabled = true, - show_file_path = true, + show_file_path = false, show_symbols = true, colors = {