From 7c3d52506c94d6f67f224c430bdae9fa2baeaf82 Mon Sep 17 00:00:00 2001 From: Georgios Atheridis Date: Sun, 5 Jun 2022 20:13:26 +0300 Subject: [PATCH] null-ls --- nvim/init.lua | 3 + nvim/lua/nvim/autopairs.lua | 90 +++--- nvim/lua/nvim/bufferline.lua | 4 +- nvim/lua/nvim/cmp.lua | 226 ++++++------- nvim/lua/nvim/colorscheme.lua | 10 +- nvim/lua/nvim/comment.lua | 8 +- nvim/lua/nvim/gitsigns.lua | 82 ++--- nvim/lua/nvim/keymaps.lua | 17 +- nvim/lua/nvim/lsp/handlers.lua | 140 ++++----- nvim/lua/nvim/lsp/init.lua | 4 +- nvim/lua/nvim/lsp/lsp-installer.lua | 42 +-- nvim/lua/nvim/lsp/settings/jsonls.lua | 350 ++++++++++----------- nvim/lua/nvim/lsp/settings/pyright.lua | 14 +- nvim/lua/nvim/lsp/settings/sumneko_lua.lua | 26 +- nvim/lua/nvim/null-ls.lua | 16 + nvim/lua/nvim/nvim-tree.lua | 344 ++++++++++---------- nvim/lua/nvim/options.lua | 66 ++-- nvim/lua/nvim/plugins.lua | 232 +++++++------- nvim/lua/nvim/telescope.lua | 176 +++++------ nvim/lua/nvim/treesitter.lua | 22 +- 20 files changed, 936 insertions(+), 936 deletions(-) create mode 100644 nvim/lua/nvim/null-ls.lua diff --git a/nvim/init.lua b/nvim/init.lua index e57a557..2fd4ae4 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -4,8 +4,11 @@ require("nvim.plugins") require("nvim.colorscheme") require("nvim.cmp") require("nvim.lsp") +require("nvim.telescope") require("nvim.autopairs") require("nvim.treesitter") require("nvim.gitsigns") +require("nvim.comment") require("nvim.nvim-tree") require("nvim.bufferline") +require("nvim.null-ls") diff --git a/nvim/lua/nvim/autopairs.lua b/nvim/lua/nvim/autopairs.lua index 1b3a2fb..bdeb26a 100644 --- a/nvim/lua/nvim/autopairs.lua +++ b/nvim/lua/nvim/autopairs.lua @@ -1,19 +1,19 @@ -- If you want insert `(` after select function or method item local status_ok, npairs = pcall(require, "nvim-autopairs") if not status_ok then - return + return end local Rule = require("nvim-autopairs.rule") -npairs.setup ({ - check_ts = true, - ts_config = { - lua = {"string"}, -- it will not add a pair on that treesitter node - javascript = {"template_string"}, - java = false, -- don't check treesitter on java - }, - map_cr = true, +npairs.setup({ + check_ts = true, + ts_config = { + lua = { "string" }, -- it will not add a pair on that treesitter node + javascript = { "template_string" }, + java = false, -- don't check treesitter on java + }, + map_cr = true, }) -- npairs.add_rules { @@ -22,45 +22,45 @@ npairs.setup ({ -- } --Add spaces between parentheses -npairs.add_rules { - Rule('{%', '%'), - Rule('{% ', ' '), - Rule(' ', ' ') - :with_pair(function (opts) - local pair = opts.line:sub(opts.col - 1, opts.col) - return vim.tbl_contains({ '()', '[]', '{}' }, pair) - end), - Rule('( ', ' )') - :with_pair(function() return false end) - :with_move(function(opts) - return opts.prev_char:match('.%)') ~= nil - end) - :use_key(')'), - Rule('{ ', ' }') - :with_pair(function() return false end) - :with_move(function(opts) - return opts.prev_char:match('.%}') ~= nil - end) - :use_key('}'), - Rule('[ ', ' ]') - :with_pair(function() return false end) - :with_move(function(opts) - return opts.prev_char:match('.%]') ~= nil - end) - :use_key(']'), -} - +npairs.add_rules({ + Rule("{%", "%"), + Rule("{% ", " "), + Rule(" ", " "):with_pair(function(opts) + local pair = opts.line:sub(opts.col - 1, opts.col) + return vim.tbl_contains({ "()", "[]", "{}" }, pair) + end), + Rule("( ", " )") + :with_pair(function() + return false + end) + :with_move(function(opts) + return opts.prev_char:match(".%)") ~= nil + end) + :use_key(")"), + Rule("{ ", " }") + :with_pair(function() + return false + end) + :with_move(function(opts) + return opts.prev_char:match(".%}") ~= nil + end) + :use_key("}"), + Rule("[ ", " ]") + :with_pair(function() + return false + end) + :with_move(function(opts) + return opts.prev_char:match(".%]") ~= nil + end) + :use_key("]"), +}) -local cmp_autopairs = require('nvim-autopairs.completion.cmp') +local cmp_autopairs = require("nvim-autopairs.completion.cmp") local cmp_status_ok, cmp = pcall(require, "cmp") if not cmp_status_ok then - return + return end -cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) - - - +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } })) -- add a lisp filetype (wrap my-function), FYI: Hardcoded = { "clojure", "clojurescript", "fennel", "janet" } -cmp_autopairs.lisp[#cmp_autopairs.lisp+1] = "racket" - +cmp_autopairs.lisp[#cmp_autopairs.lisp + 1] = "racket" diff --git a/nvim/lua/nvim/bufferline.lua b/nvim/lua/nvim/bufferline.lua index 5fd6322..b23f016 100644 --- a/nvim/lua/nvim/bufferline.lua +++ b/nvim/lua/nvim/bufferline.lua @@ -3,7 +3,7 @@ if not status_ok then return end -bufferline.setup { +bufferline.setup({ options = { numbers = "none", close_command = "Bdelete! %d", @@ -24,4 +24,4 @@ bufferline.setup { enforce_regular_tabs = true, always_show_bufferline = true, }, -} +}) diff --git a/nvim/lua/nvim/cmp.lua b/nvim/lua/nvim/cmp.lua index 711d6a7..b968023 100644 --- a/nvim/lua/nvim/cmp.lua +++ b/nvim/lua/nvim/cmp.lua @@ -1,136 +1,136 @@ local cmp_status_ok, cmp = pcall(require, "cmp") if not cmp_status_ok then - print("Error loading cmp") - return + print("Error loading cmp") + return end local snip_status_ok, luasnip = pcall(require, "luasnip") if not snip_status_ok then - print("Error loading snip") - return + print("Error loading snip") + return end require("luasnip/loaders/from_vscode").lazy_load() local check_backspace = function() - local col = vim.fn.col "." - 1 - return col == 0 or vim.fn.getline("."):sub(col, col):match "%s" + local col = vim.fn.col(".") - 1 + return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") end --   פּ ﯟ   some other good icons local kind_icons = { - Text = "", - Method = "m", - Function = "", - Constructor = "", - Field = "", - Variable = "", - Class = "", - Interface = "", - Module = "", - Property = "", - Unit = "", - Value = "", - Enum = "", - Keyword = "", - Snippet = "", - Color = "", - File = "", - Reference = "", - Folder = "", - EnumMember = "", - Constant = "", - Struct = "", - Event = "", - Operator = "", - TypeParameter = "", + Text = "", + Method = "m", + Function = "", + Constructor = "", + Field = "", + Variable = "", + Class = "", + Interface = "", + Module = "", + Property = "", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "", } -cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = { - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), - [""] = cmp.mapping { - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }, - [""] = cmp.mapping.confirm { select = false }, - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expandable() then - luasnip.expand() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif check_backspace() then - fallback() - else - fallback() - end - end, { - "i", - "s", - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { - "i", - "s", - }), - }, - formatting = { - fields = { "kind", "abbr", "menu" }, - }, - sources = { - { name = "nvim_lsp" }, - { name = "nvim_lua" }, - { name = "luasnip" }, - { name = "buffer" }, - { name = "path" }, - }, - confirm_opts = { - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }, - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - experimental = { - ghost_text = true, - }, -} +cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = { + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + [""] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + [""] = cmp.mapping.confirm({ select = false }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expandable() then + luasnip.expand() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif check_backspace() then + fallback() + else + fallback() + end + end, { + "i", + "s", + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { + "i", + "s", + }), + }, + formatting = { + fields = { "kind", "abbr", "menu" }, + }, + sources = { + { name = "nvim_lsp" }, + { name = "nvim_lua" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + experimental = { + ghost_text = true, + }, +}) -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline('/', { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = 'buffer' } - } +cmp.setup.cmdline("/", { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, }) -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline(':', { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }) +cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), }) diff --git a/nvim/lua/nvim/colorscheme.lua b/nvim/lua/nvim/colorscheme.lua index 7c7ca34..328ac47 100644 --- a/nvim/lua/nvim/colorscheme.lua +++ b/nvim/lua/nvim/colorscheme.lua @@ -1,10 +1,10 @@ local status_ok, onedark = pcall(require, "onedark") if not status_ok then - vim.notify("Error with colorscheme") - return + vim.notify("Error with colorscheme") + return end -onedark.setup { - style = "deep" -} +onedark.setup({ + style = "deep", +}) onedark.load() diff --git a/nvim/lua/nvim/comment.lua b/nvim/lua/nvim/comment.lua index 2283528..1a52688 100644 --- a/nvim/lua/nvim/comment.lua +++ b/nvim/lua/nvim/comment.lua @@ -3,7 +3,7 @@ if not status_ok then return end -comment.setup { +comment.setup({ pre_hook = function(ctx) local U = require("Comment.utils") @@ -14,9 +14,9 @@ comment.setup { location = require("ts_context_commentstring.utils").get_visual_start_location() end - return require("ts_context_commentstring.internal").calculate_commentstring { + return require("ts_context_commentstring.internal").calculate_commentstring({ key = ctx.ctype == U.ctype.line and "__default" or "__multiline", location = location, - } + }) end, -} +}) diff --git a/nvim/lua/nvim/gitsigns.lua b/nvim/lua/nvim/gitsigns.lua index 064fe38..f141870 100644 --- a/nvim/lua/nvim/gitsigns.lua +++ b/nvim/lua/nvim/gitsigns.lua @@ -3,44 +3,44 @@ if not status_ok then return end -gitsigns.setup { - signs = { - add = {hl = 'GitSignsAdd' , text = '▎', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'}, - change = {hl = 'GitSignsChange', text = '▎', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, - delete = {hl = 'GitSignsDelete', text = '_', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, - topdelete = {hl = 'GitSignsDelete', text = '‾', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, - changedelete = {hl = 'GitSignsChange', text = '~', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, - }, - signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` - numhl = false, -- Toggle with `:Gitsigns toggle_numhl` - linehl = false, -- Toggle with `:Gitsigns toggle_linehl` - word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` - watch_gitdir = { - interval = 1000, - follow_files = true - }, - attach_to_untracked = true, - current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` - current_line_blame_opts = { - virt_text = true, - virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' - delay = 1000, - ignore_whitespace = false, - }, - current_line_blame_formatter = ', - ', - sign_priority = 6, - update_debounce = 100, - status_formatter = nil, -- Use default - max_file_length = 40000, - preview_config = { - -- Options passed to nvim_open_win - border = 'single', - style = 'minimal', - relative = 'cursor', - row = 0, - col = 1 - }, - yadm = { - enable = false - }, -} +gitsigns.setup({ + signs = { + add = { hl = "GitSignsAdd", text = "▎", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, + change = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + delete = { hl = "GitSignsDelete", text = "_", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + topdelete = { hl = "GitSignsDelete", text = "‾", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + changedelete = { hl = "GitSignsChange", text = "~", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + }, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = false, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + watch_gitdir = { + interval = 1000, + follow_files = true, + }, + attach_to_untracked = true, + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + ignore_whitespace = false, + }, + current_line_blame_formatter = ", - ", + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, + preview_config = { + -- Options passed to nvim_open_win + border = "single", + style = "minimal", + relative = "cursor", + row = 0, + col = 1, + }, + yadm = { + enable = false, + }, +}) diff --git a/nvim/lua/nvim/keymaps.lua b/nvim/lua/nvim/keymaps.lua index b4d10f1..3bf231e 100644 --- a/nvim/lua/nvim/keymaps.lua +++ b/nvim/lua/nvim/keymaps.lua @@ -1,19 +1,19 @@ local opts = { noremap = true, silent = true } local function nnoremap(shortcut, command) - vim.keymap.set("n", shortcut, command, opts) + vim.keymap.set("n", shortcut, command, opts) end local function inoremap(shortcut, command) - vim.keymap.set("i", shortcut, command, opts) + vim.keymap.set("i", shortcut, command, opts) end local function vnoremap(shortcut, command) - vim.keymap.set("v", shortcut, command, opts) + vim.keymap.set("v", shortcut, command, opts) end local function xnoremap(shortcut, command) - vim.keymap.set("x", shortcut, command, opts) + vim.keymap.set("x", shortcut, command, opts) end local function tnoremap(shortcut, command) - vim.keymap.set("t", shortcut, command, opts) + vim.keymap.set("t", shortcut, command, opts) end -- Define leader key @@ -47,7 +47,7 @@ inoremap("jk", "") -- Don't copy replaced text into register -- while in visual mode, when pasting -vnoremap("p", "\"_dP") +vnoremap("p", '"_dP') -- Move text up and down vnoremap("", ":m .+1==") @@ -66,5 +66,8 @@ tnoremap("", "k") tnoremap("", "l") -- Telescope -nnoremap("f", "lua require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ previewer = false }))") +nnoremap( + "f", + "lua require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ previewer = false }))" +) nnoremap("", "Telescope live_grep") diff --git a/nvim/lua/nvim/lsp/handlers.lua b/nvim/lua/nvim/lsp/handlers.lua index 551a526..64d1e5f 100644 --- a/nvim/lua/nvim/lsp/handlers.lua +++ b/nvim/lua/nvim/lsp/handlers.lua @@ -2,101 +2,101 @@ local M = {} -- TODO: backfill this to template M.setup = function() - local signs = { - { name = "DiagnosticSignError", text = "" }, - { name = "DiagnosticSignWarn", text = "" }, - { name = "DiagnosticSignHint", text = "" }, - { name = "DiagnosticSignInfo", text = "" }, - } - - for _, sign in ipairs(signs) do - vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) - end + local signs = { + { name = "DiagnosticSignError", text = "" }, + { name = "DiagnosticSignWarn", text = "" }, + { name = "DiagnosticSignHint", text = "" }, + { name = "DiagnosticSignInfo", text = "" }, + } - local config = { - -- disable virtual text - virtual_text = true, - -- show signs - signs = { - active = signs, - }, - update_in_insert = true, - underline = true, - severity_sort = true, - float = { - focusable = false, - style = "minimal", - border = "rounded", - source = "always", - header = "", - prefix = "", - }, - } + for _, sign in ipairs(signs) do + vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) + end - vim.diagnostic.config(config) + local config = { + -- disable virtual text + virtual_text = true, + -- show signs + signs = { + active = signs, + }, + update_in_insert = true, + underline = true, + severity_sort = true, + float = { + focusable = false, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + } - vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { - border = "rounded", - }) + vim.diagnostic.config(config) - vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { - border = "rounded", - }) + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = "rounded", + }) + + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = "rounded", + }) end local function lsp_highlight_document(client) - -- Set autocommands conditional on server_capabilities - if client.resolved_capabilities.document_highlight then - vim.api.nvim_exec( - [[ + -- Set autocommands conditional on server_capabilities + if client.resolved_capabilities.document_highlight then + vim.api.nvim_exec( + [[ augroup lsp_document_highlight autocmd! * autocmd CursorHold lua vim.lsp.buf.document_highlight() autocmd CursorMoved lua vim.lsp.buf.clear_references() augroup END ]], - false - ) - end + false + ) + end end local function lsp_keymaps(bufnr) - 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) - vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "lua vim.lsp.buf.hover()", opts) - vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "lua vim.lsp.buf.implementation()", 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", "gr", "lua vim.lsp.buf.references()", 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", - "gl", - 'lua vim.lsp.diagnostic.show_line_diagnostics({ 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.formatting()' ]] + 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) + vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "lua vim.lsp.buf.hover()", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "lua vim.lsp.buf.implementation()", 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", "gr", "lua vim.lsp.buf.references()", 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", + "gl", + 'lua vim.lsp.diagnostic.show_line_diagnostics({ 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.formatting()' ]]) end M.on_attach = function(client, bufnr) - if client.name == "tsserver" then - client.resolved_capabilities.document_formatting = false - end - lsp_keymaps(bufnr) - lsp_highlight_document(client) + if client.name == "tsserver" or client.name == "sumneko_lua" then + client.resolved_capabilities.document_formatting = false + end + lsp_keymaps(bufnr) + lsp_highlight_document(client) end local capabilities = vim.lsp.protocol.make_client_capabilities() local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") if not status_ok then - return + return end M.capabilities = cmp_nvim_lsp.update_capabilities(capabilities) diff --git a/nvim/lua/nvim/lsp/init.lua b/nvim/lua/nvim/lsp/init.lua index e66a929..64a82e7 100644 --- a/nvim/lua/nvim/lsp/init.lua +++ b/nvim/lua/nvim/lsp/init.lua @@ -1,7 +1,7 @@ local status_ok, _ = pcall(require, "lspconfig") if not status_ok then - print("Error with lspconfig") - return + print("Error with lspconfig") + return end require("nvim.lsp.lsp-installer") diff --git a/nvim/lua/nvim/lsp/lsp-installer.lua b/nvim/lua/nvim/lsp/lsp-installer.lua index cef26ac..6e2188f 100644 --- a/nvim/lua/nvim/lsp/lsp-installer.lua +++ b/nvim/lua/nvim/lsp/lsp-installer.lua @@ -1,33 +1,33 @@ local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer") if not status_ok then - print("Error with nvim-lsp-installer") - return + print("Error with nvim-lsp-installer") + return end -- Register a handler that will be called for all installed servers. -- Alternatively, you may also register handlers on specific server instances instead (see example below). lsp_installer.on_server_ready(function(server) - local opts = { - on_attach = require("nvim.lsp.handlers").on_attach, - capabilities = require("nvim.lsp.handlers").capabilities, - } + local opts = { + on_attach = require("nvim.lsp.handlers").on_attach, + capabilities = require("nvim.lsp.handlers").capabilities, + } - if server.name == "jsonls" then - local jsonls_opts = require("nvim.lsp.settings.jsonls") - opts = vim.tbl_deep_extend("force", jsonls_opts, opts) - end + if server.name == "jsonls" then + local jsonls_opts = require("nvim.lsp.settings.jsonls") + opts = vim.tbl_deep_extend("force", jsonls_opts, opts) + end - if server.name == "sumneko_lua" then - local sumneko_opts = require("nvim.lsp.settings.sumneko_lua") - opts = vim.tbl_deep_extend("force", sumneko_opts, opts) - end + if server.name == "sumneko_lua" then + local sumneko_opts = require("nvim.lsp.settings.sumneko_lua") + opts = vim.tbl_deep_extend("force", sumneko_opts, opts) + end - if server.name == "pyright" then - local pyright_opts = require("nvim.lsp.settings.pyright") - opts = vim.tbl_deep_extend("force", pyright_opts, opts) - end + if server.name == "pyright" then + local pyright_opts = require("nvim.lsp.settings.pyright") + opts = vim.tbl_deep_extend("force", pyright_opts, opts) + end - -- This setup() function is exactly the same as lspconfig's setup function. - -- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md - server:setup(opts) + -- This setup() function is exactly the same as lspconfig's setup function. + -- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md + server:setup(opts) end) diff --git a/nvim/lua/nvim/lsp/settings/jsonls.lua b/nvim/lua/nvim/lsp/settings/jsonls.lua index be362c9..31fb914 100644 --- a/nvim/lua/nvim/lsp/settings/jsonls.lua +++ b/nvim/lua/nvim/lsp/settings/jsonls.lua @@ -1,183 +1,183 @@ -- Find more schemas here: https://www.schemastore.org/json/ local schemas = { - { - description = "TypeScript compiler configuration file", - fileMatch = { - "tsconfig.json", - "tsconfig.*.json", - }, - url = "https://json.schemastore.org/tsconfig.json", - }, - { - description = "Lerna config", - fileMatch = { "lerna.json" }, - url = "https://json.schemastore.org/lerna.json", - }, - { - description = "Babel configuration", - fileMatch = { - ".babelrc.json", - ".babelrc", - "babel.config.json", - }, - url = "https://json.schemastore.org/babelrc.json", - }, - { - description = "ESLint config", - fileMatch = { - ".eslintrc.json", - ".eslintrc", - }, - url = "https://json.schemastore.org/eslintrc.json", - }, - { - description = "Bucklescript config", - fileMatch = { "bsconfig.json" }, - url = "https://raw.githubusercontent.com/rescript-lang/rescript-compiler/8.2.0/docs/docson/build-schema.json", - }, - { - description = "Prettier config", - fileMatch = { - ".prettierrc", - ".prettierrc.json", - "prettier.config.json", - }, - url = "https://json.schemastore.org/prettierrc", - }, - { - description = "Vercel Now config", - fileMatch = { "now.json" }, - url = "https://json.schemastore.org/now", - }, - { - description = "Stylelint config", - fileMatch = { - ".stylelintrc", - ".stylelintrc.json", - "stylelint.config.json", - }, - url = "https://json.schemastore.org/stylelintrc", - }, - { - description = "A JSON schema for the ASP.NET LaunchSettings.json files", - fileMatch = { "launchsettings.json" }, - url = "https://json.schemastore.org/launchsettings.json", - }, - { - description = "Schema for CMake Presets", - fileMatch = { - "CMakePresets.json", - "CMakeUserPresets.json", - }, - url = "https://raw.githubusercontent.com/Kitware/CMake/master/Help/manual/presets/schema.json", - }, - { - description = "Configuration file as an alternative for configuring your repository in the settings page.", - fileMatch = { - ".codeclimate.json", - }, - url = "https://json.schemastore.org/codeclimate.json", - }, - { - description = "LLVM compilation database", - fileMatch = { - "compile_commands.json", - }, - url = "https://json.schemastore.org/compile-commands.json", - }, - { - description = "Config file for Command Task Runner", - fileMatch = { - "commands.json", - }, - url = "https://json.schemastore.org/commands.json", - }, - { - description = "AWS CloudFormation provides a common language for you to describe and provision all the infrastructure resources in your cloud environment.", - fileMatch = { - "*.cf.json", - "cloudformation.json", - }, - url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/cloudformation.schema.json", - }, - { - description = "The AWS Serverless Application Model (AWS SAM, previously known as Project Flourish) extends AWS CloudFormation to provide a simplified way of defining the Amazon API Gateway APIs, AWS Lambda functions, and Amazon DynamoDB tables needed by your serverless application.", - fileMatch = { - "serverless.template", - "*.sam.json", - "sam.json", - }, - url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/sam.schema.json", - }, - { - description = "Json schema for properties json file for a GitHub Workflow template", - fileMatch = { - ".github/workflow-templates/**.properties.json", - }, - url = "https://json.schemastore.org/github-workflow-template-properties.json", - }, - { - description = "golangci-lint configuration file", - fileMatch = { - ".golangci.toml", - ".golangci.json", - }, - url = "https://json.schemastore.org/golangci-lint.json", - }, - { - description = "JSON schema for the JSON Feed format", - fileMatch = { - "feed.json", - }, - url = "https://json.schemastore.org/feed.json", - versions = { - ["1"] = "https://json.schemastore.org/feed-1.json", - ["1.1"] = "https://json.schemastore.org/feed.json", - }, - }, - { - description = "Packer template JSON configuration", - fileMatch = { - "packer.json", - }, - url = "https://json.schemastore.org/packer.json", - }, - { - description = "NPM configuration file", - fileMatch = { - "package.json", - }, - url = "https://json.schemastore.org/package.json", - }, - { - description = "JSON schema for Visual Studio component configuration files", - fileMatch = { - "*.vsconfig", - }, - url = "https://json.schemastore.org/vsconfig.json", - }, - { - description = "Resume json", - fileMatch = { "resume.json" }, - url = "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json", - }, + { + description = "TypeScript compiler configuration file", + fileMatch = { + "tsconfig.json", + "tsconfig.*.json", + }, + url = "https://json.schemastore.org/tsconfig.json", + }, + { + description = "Lerna config", + fileMatch = { "lerna.json" }, + url = "https://json.schemastore.org/lerna.json", + }, + { + description = "Babel configuration", + fileMatch = { + ".babelrc.json", + ".babelrc", + "babel.config.json", + }, + url = "https://json.schemastore.org/babelrc.json", + }, + { + description = "ESLint config", + fileMatch = { + ".eslintrc.json", + ".eslintrc", + }, + url = "https://json.schemastore.org/eslintrc.json", + }, + { + description = "Bucklescript config", + fileMatch = { "bsconfig.json" }, + url = "https://raw.githubusercontent.com/rescript-lang/rescript-compiler/8.2.0/docs/docson/build-schema.json", + }, + { + description = "Prettier config", + fileMatch = { + ".prettierrc", + ".prettierrc.json", + "prettier.config.json", + }, + url = "https://json.schemastore.org/prettierrc", + }, + { + description = "Vercel Now config", + fileMatch = { "now.json" }, + url = "https://json.schemastore.org/now", + }, + { + description = "Stylelint config", + fileMatch = { + ".stylelintrc", + ".stylelintrc.json", + "stylelint.config.json", + }, + url = "https://json.schemastore.org/stylelintrc", + }, + { + description = "A JSON schema for the ASP.NET LaunchSettings.json files", + fileMatch = { "launchsettings.json" }, + url = "https://json.schemastore.org/launchsettings.json", + }, + { + description = "Schema for CMake Presets", + fileMatch = { + "CMakePresets.json", + "CMakeUserPresets.json", + }, + url = "https://raw.githubusercontent.com/Kitware/CMake/master/Help/manual/presets/schema.json", + }, + { + description = "Configuration file as an alternative for configuring your repository in the settings page.", + fileMatch = { + ".codeclimate.json", + }, + url = "https://json.schemastore.org/codeclimate.json", + }, + { + description = "LLVM compilation database", + fileMatch = { + "compile_commands.json", + }, + url = "https://json.schemastore.org/compile-commands.json", + }, + { + description = "Config file for Command Task Runner", + fileMatch = { + "commands.json", + }, + url = "https://json.schemastore.org/commands.json", + }, + { + description = "AWS CloudFormation provides a common language for you to describe and provision all the infrastructure resources in your cloud environment.", + fileMatch = { + "*.cf.json", + "cloudformation.json", + }, + url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/cloudformation.schema.json", + }, + { + description = "The AWS Serverless Application Model (AWS SAM, previously known as Project Flourish) extends AWS CloudFormation to provide a simplified way of defining the Amazon API Gateway APIs, AWS Lambda functions, and Amazon DynamoDB tables needed by your serverless application.", + fileMatch = { + "serverless.template", + "*.sam.json", + "sam.json", + }, + url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/sam.schema.json", + }, + { + description = "Json schema for properties json file for a GitHub Workflow template", + fileMatch = { + ".github/workflow-templates/**.properties.json", + }, + url = "https://json.schemastore.org/github-workflow-template-properties.json", + }, + { + description = "golangci-lint configuration file", + fileMatch = { + ".golangci.toml", + ".golangci.json", + }, + url = "https://json.schemastore.org/golangci-lint.json", + }, + { + description = "JSON schema for the JSON Feed format", + fileMatch = { + "feed.json", + }, + url = "https://json.schemastore.org/feed.json", + versions = { + ["1"] = "https://json.schemastore.org/feed-1.json", + ["1.1"] = "https://json.schemastore.org/feed.json", + }, + }, + { + description = "Packer template JSON configuration", + fileMatch = { + "packer.json", + }, + url = "https://json.schemastore.org/packer.json", + }, + { + description = "NPM configuration file", + fileMatch = { + "package.json", + }, + url = "https://json.schemastore.org/package.json", + }, + { + description = "JSON schema for Visual Studio component configuration files", + fileMatch = { + "*.vsconfig", + }, + url = "https://json.schemastore.org/vsconfig.json", + }, + { + description = "Resume json", + fileMatch = { "resume.json" }, + url = "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json", + }, } local opts = { - settings = { - json = { - schemas = schemas, - }, - }, - setup = { - commands = { - Format = { - function() - vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 }) - end, - }, - }, - }, + settings = { + json = { + schemas = schemas, + }, + }, + setup = { + commands = { + Format = { + function() + vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line("$"), 0 }) + end, + }, + }, + }, } return opts diff --git a/nvim/lua/nvim/lsp/settings/pyright.lua b/nvim/lua/nvim/lsp/settings/pyright.lua index 1fe7686..8b89983 100644 --- a/nvim/lua/nvim/lsp/settings/pyright.lua +++ b/nvim/lua/nvim/lsp/settings/pyright.lua @@ -1,9 +1,9 @@ return { - settings = { - python = { - analysis = { - typeCheckingMode = "basic", - } - } - }, + settings = { + python = { + analysis = { + typeCheckingMode = "basic", + }, + }, + }, } diff --git a/nvim/lua/nvim/lsp/settings/sumneko_lua.lua b/nvim/lua/nvim/lsp/settings/sumneko_lua.lua index 9848bdd..6d27e62 100644 --- a/nvim/lua/nvim/lsp/settings/sumneko_lua.lua +++ b/nvim/lua/nvim/lsp/settings/sumneko_lua.lua @@ -1,15 +1,15 @@ return { - settings = { - Lua = { - diagnostics = { - globals = { "vim" }, - }, - workspace = { - library = { - [vim.fn.expand("$VIMRUNTIME/lua")] = true, - [vim.fn.stdpath("config") .. "/lua"] = true, - }, - }, - }, - }, + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + }, + }, + }, } diff --git a/nvim/lua/nvim/null-ls.lua b/nvim/lua/nvim/null-ls.lua new file mode 100644 index 0000000..23639ca --- /dev/null +++ b/nvim/lua/nvim/null-ls.lua @@ -0,0 +1,16 @@ +local null_ls_status_ok, null_ls = pcall(require, "null-ls") +if not null_ls_status_ok then + return +end + +local formatting = null_ls.builtins.formatting +local diagnostics = null_ls.builtins.diagnostics + +null_ls.setup({ + debug = false, + sources = { + formatting.black, + formatting.stylua, + diagnostics.flake8, + }, +}) diff --git a/nvim/lua/nvim/nvim-tree.lua b/nvim/lua/nvim/nvim-tree.lua index 1193898..e5ea9a4 100644 --- a/nvim/lua/nvim/nvim-tree.lua +++ b/nvim/lua/nvim/nvim-tree.lua @@ -8,175 +8,175 @@ local tree_cb = nvim_tree_config.nvim_tree_callback -- setup with all defaults -- each of these are documented in `:help nvim-tree.OPTION_NAME` -- nested options are documented by accessing them with `.` (eg: `:help nvim-tree.view.mappings.list`). -require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS - auto_reload_on_write = true, - create_in_closed_folder = false, - disable_netrw = false, - hijack_cursor = false, - hijack_netrw = true, - hijack_unnamed_buffer_when_opening = false, - ignore_buffer_on_setup = false, - open_on_setup = false, - open_on_setup_file = false, - open_on_tab = false, - sort_by = "name", - update_cwd = false, - reload_on_bufenter = false, - respect_buf_cwd = false, - view = { - adaptive_size = false, - width = 20, - height = 30, - hide_root_folder = false, - side = "left", - preserve_window_proportions = false, - number = false, - relativenumber = false, - signcolumn = "yes", - 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" }, - }, - }, - }, - renderer = { - add_trailing = false, - group_empty = false, - highlight_git = false, - highlight_opened_files = "none", - root_folder_modifier = ":~", - indent_markers = { - enable = false, - icons = { - corner = "└ ", - edge = "│ ", - item = "│ ", - none = " ", - }, - }, - icons = { - webdev_colors = true, - git_placement = "before", - padding = " ", - symlink_arrow = " ➛ ", - show = { - file = true, - folder = true, - folder_arrow = true, - git = true, - }, - glyphs = { - default = "", - symlink = "", - folder = { - arrow_closed = "", - arrow_open = "", - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", - symlink_open = "", - }, - git = { - unstaged = "✗", - staged = "✓", - unmerged = "", - renamed = "➜", - untracked = "★", - deleted = "", - ignored = "◌", - }, - }, - }, - special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" }, - }, - hijack_directories = { - enable = true, - auto_open = true, - }, - update_focused_file = { - enable = false, - update_cwd = false, - ignore_list = {}, - }, - ignore_ft_on_setup = {}, - system_open = { - cmd = "", - args = {}, - }, - diagnostics = { - enable = true, - show_on_dirs = true, - icons = { - hint = "", - info = "", - warning = "", - error = "", - }, - }, - filters = { - dotfiles = false, - custom = {}, - exclude = {}, - }, - filesystem_watchers = { - enable = false, - interval = 100, - }, - git = { - enable = true, - ignore = true, - timeout = 400, - }, - actions = { - use_system_clipboard = true, - change_dir = { - enable = true, - global = false, - restrict_above_cwd = false, - }, - expand_all = { - max_folder_discovery = 300, - }, - open_file = { - quit_on_open = false, - resize_window = true, - window_picker = { - enable = true, - chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", - exclude = { - filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, - buftype = { "nofile", "terminal", "help" }, - }, - }, - }, - remove_file = { - close_window = true, - }, - }, - trash = { - cmd = "trash", - require_confirm = true, - }, - live_filter = { - prefix = "[FILTER]: ", - always_show_folders = true, - }, - log = { - enable = false, - truncate = false, - types = { - all = false, - config = false, - copy_paste = false, - diagnostics = false, - git = false, - profile = false, - watcher = false, - }, - }, -} -- END_DEFAULT_OPTS +require("nvim-tree").setup({ -- BEGIN_DEFAULT_OPTS + auto_reload_on_write = true, + create_in_closed_folder = false, + disable_netrw = false, + hijack_cursor = false, + hijack_netrw = true, + hijack_unnamed_buffer_when_opening = false, + ignore_buffer_on_setup = false, + open_on_setup = false, + open_on_setup_file = false, + open_on_tab = false, + sort_by = "name", + update_cwd = false, + reload_on_bufenter = false, + respect_buf_cwd = false, + view = { + adaptive_size = false, + width = 30, + height = 30, + hide_root_folder = false, + side = "left", + preserve_window_proportions = false, + number = false, + relativenumber = false, + signcolumn = "yes", + 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") }, + }, + }, + }, + renderer = { + add_trailing = false, + group_empty = false, + highlight_git = false, + highlight_opened_files = "none", + root_folder_modifier = ":~", + indent_markers = { + enable = false, + icons = { + corner = "└ ", + edge = "│ ", + item = "│ ", + none = " ", + }, + }, + icons = { + webdev_colors = true, + git_placement = "before", + padding = " ", + symlink_arrow = " ➛ ", + show = { + file = true, + folder = true, + folder_arrow = true, + git = true, + }, + glyphs = { + default = "", + symlink = "", + folder = { + arrow_closed = "", + arrow_open = "", + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + symlink_open = "", + }, + git = { + unstaged = "✗", + staged = "✓", + unmerged = "", + renamed = "➜", + untracked = "★", + deleted = "", + ignored = "◌", + }, + }, + }, + special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" }, + }, + hijack_directories = { + enable = true, + auto_open = true, + }, + update_focused_file = { + enable = false, + update_cwd = false, + ignore_list = {}, + }, + ignore_ft_on_setup = {}, + system_open = { + cmd = "", + args = {}, + }, + diagnostics = { + enable = true, + show_on_dirs = true, + icons = { + hint = "", + info = "", + warning = "", + error = "", + }, + }, + filters = { + dotfiles = false, + custom = {}, + exclude = {}, + }, + filesystem_watchers = { + enable = false, + interval = 100, + }, + git = { + enable = true, + ignore = true, + timeout = 400, + }, + actions = { + use_system_clipboard = true, + change_dir = { + enable = true, + global = false, + restrict_above_cwd = false, + }, + expand_all = { + max_folder_discovery = 300, + }, + open_file = { + quit_on_open = false, + resize_window = true, + window_picker = { + enable = true, + chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", + exclude = { + filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, + buftype = { "nofile", "terminal", "help" }, + }, + }, + }, + remove_file = { + close_window = true, + }, + }, + trash = { + cmd = "trash", + require_confirm = true, + }, + live_filter = { + prefix = "[FILTER]: ", + always_show_folders = true, + }, + log = { + enable = false, + truncate = false, + types = { + all = false, + config = false, + copy_paste = false, + diagnostics = false, + git = false, + profile = false, + watcher = false, + }, + }, +}) -- END_DEFAULT_OPTS diff --git a/nvim/lua/nvim/options.lua b/nvim/lua/nvim/options.lua index 9ed4443..a6e3feb 100644 --- a/nvim/lua/nvim/options.lua +++ b/nvim/lua/nvim/options.lua @@ -1,39 +1,39 @@ local options = { - backup = false, - clipboard = "unnamedplus", - cmdheight = 1, - completeopt = { "menuone", "noselect" }, - conceallevel = 0, - fileencoding = "utf-8", - hlsearch = false, - showtabline = 4, - pumheight = 10, - smartcase = true, - smartindent = true, - splitbelow = true, - splitright = true, - swapfile = false, - termguicolors = true, - timeoutlen = 1000, - undofile = true, - updatetime = 300, - writebackup = false, - expandtab = false, - shiftwidth = 4, - tabstop = 4, - number = true, - relativenumber = true, - cursorline = true, - numberwidth = 4, - signcolumn = "yes", - wrap = false, - scrolloff = 8, - sidescrolloff = 8, - guifont = "monospace:h17", + backup = false, + clipboard = "unnamedplus", + cmdheight = 1, + completeopt = { "menuone", "noselect" }, + conceallevel = 0, + fileencoding = "utf-8", + hlsearch = false, + showtabline = 4, + pumheight = 10, + smartcase = true, + smartindent = true, + splitbelow = true, + splitright = true, + swapfile = false, + termguicolors = true, + timeoutlen = 1000, + undofile = true, + updatetime = 300, + writebackup = false, + expandtab = false, + shiftwidth = 4, + tabstop = 4, + number = true, + relativenumber = true, + cursorline = true, + numberwidth = 4, + signcolumn = "yes", + wrap = false, + scrolloff = 8, + sidescrolloff = 8, + guifont = "monospace:h17", } -vim.opt.shortmess:append "c" +vim.opt.shortmess:append("c") for k, v in pairs(options) do - vim.opt[k] = v + vim.opt[k] = v end diff --git a/nvim/lua/nvim/plugins.lua b/nvim/lua/nvim/plugins.lua index 6f76882..aefad83 100644 --- a/nvim/lua/nvim/plugins.lua +++ b/nvim/lua/nvim/plugins.lua @@ -1,141 +1,133 @@ local fn = vim.fn -- Automatically install packer -local install_path = fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim" +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]] + 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 whenver you save the plugins.lua file -vim.cmd [[ +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 the first use local status_ok, packer = pcall(require, "packer") if not status_ok then - vim.notify("Error with require packer") - return + vim.notify("Error with require packer") + return end -packer.init { - display = { - open_fn = function() - return require("packer.util").float {} - end, - }, -} +packer.init({ + display = { + open_fn = function() + return require("packer.util").float({}) + end, + }, +}) -- Install plugins here return packer.startup(function(use) - use "wbthomason/packer.nvim" -- Have packer manage itself - - - - -- PLUGINS BEGIN -- - -- An implementation of the Popup API from vim in Neovim - use "nvim-lua/popup.nvim" - - -- Useful lua functions used by lots of plugins - use "nvim-lua/plenary.nvim" - - -- Preview markdown files - use({ - "iamcco/markdown-preview.nvim", - run = function() vim.fn["mkdp#util#install"]() end, - }) - - -- Colorschemes - use "navarasu/onedark.nvim" - - -- cmp Plugins - use "hrsh7th/nvim-cmp" - use "hrsh7th/cmp-buffer" - use "hrsh7th/cmp-path" - use "hrsh7th/cmp-cmdline" - use "saadparwaiz1/cmp_luasnip" - use "hrsh7th/cmp-nvim-lsp" - use "hrsh7th/cmp-nvim-lua" - - -- snippets - use "L3MON4D3/LuaSnip" - use "rafamadriz/friendly-snippets" -- a bunch of snippets to use - - -- LSP - use "neovim/nvim-lspconfig" -- enable LSP - use "williamboman/nvim-lsp-installer" -- simple to use language server installer - - --Telescope - use { - "nvim-telescope/telescope.nvim", - requires = { - { "nvim-lua/plenary.nvim" }, - -- { "nvim-telescope/telescope-media-files.nvim" }, - { "BurntSushi/ripgrep" }, - }, - } - - -- Commenter - use { - "numToStr/Comment.nvim", - config = function() - require("Comment").setup() - end - } - use 'JoosepAlviste/nvim-ts-context-commentstring' - - -- Treesitter - use { - "nvim-treesitter/nvim-treesitter", - run = ":TSUpdate", - } - use { "p00f/nvim-ts-rainbow" , - requires = { - { "nvim-treesitter/nvim-treesitter" } - } - } - - -- Autopairs - use "windwp/nvim-autopairs" - - -- Git - use "lewis6991/gitsigns.nvim" - - -- NvimTree - use { "kyazdani42/nvim-tree.lua", - requires = { - "kyazdani42/nvim-web-devicons" - }, - } - - -- Bufferline - use { "akinsho/bufferline.nvim", - requires = { - "kyazdani42/nvim-web-devicons" - }, - } - use "moll/vim-bbye" - - -- PLUGINS END -- - - - - - -- 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 + use("wbthomason/packer.nvim") -- Have packer manage itself + + -- PLUGINS BEGIN -- + -- An implementation of the Popup API from vim in Neovim + use("nvim-lua/popup.nvim") + + -- Useful lua functions used by lots of plugins + use("nvim-lua/plenary.nvim") + + -- Preview markdown files + use({ + "iamcco/markdown-preview.nvim", + run = function() + vim.fn["mkdp#util#install"]() + end, + }) + + -- Colorschemes + use("navarasu/onedark.nvim") + + -- cmp Plugins + use("hrsh7th/nvim-cmp") + use("hrsh7th/cmp-buffer") + use("hrsh7th/cmp-path") + use("hrsh7th/cmp-cmdline") + use("saadparwaiz1/cmp_luasnip") + use("hrsh7th/cmp-nvim-lsp") + use("hrsh7th/cmp-nvim-lua") + + -- snippets + use("L3MON4D3/LuaSnip") + use("rafamadriz/friendly-snippets") -- a bunch of snippets to use + + -- LSP + use("neovim/nvim-lspconfig") -- enable LSP + use("williamboman/nvim-lsp-installer") -- simple to use language server installer + use("jose-elias-alvarez/null-ls.nvim") + + --Telescope + use({ + "nvim-telescope/telescope.nvim", + requires = { + { "nvim-lua/plenary.nvim" }, + -- { "nvim-telescope/telescope-media-files.nvim" }, + { "BurntSushi/ripgrep" }, + }, + }) + + -- Commenter + use({ + "numToStr/Comment.nvim", + config = function() + require("Comment").setup() + end, + }) + use("JoosepAlviste/nvim-ts-context-commentstring") + + -- Treesitter + use({ + "nvim-treesitter/nvim-treesitter", + run = ":TSUpdate", + }) + use({ "p00f/nvim-ts-rainbow", requires = { + { "nvim-treesitter/nvim-treesitter" }, + } }) + + -- Autopairs + use("windwp/nvim-autopairs") + + -- Git + use("lewis6991/gitsigns.nvim") + + -- NvimTree + use({ "kyazdani42/nvim-tree.lua", requires = { + "kyazdani42/nvim-web-devicons", + } }) + + -- Bufferline + use({ "akinsho/bufferline.nvim", requires = { + "kyazdani42/nvim-web-devicons", + } }) + use("moll/vim-bbye") + + -- PLUGINS END -- + + -- 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/lua/nvim/telescope.lua b/nvim/lua/nvim/telescope.lua index f0d01b1..d634eba 100644 --- a/nvim/lua/nvim/telescope.lua +++ b/nvim/lua/nvim/telescope.lua @@ -1,104 +1,90 @@ local status_ok, telescope = pcall(require, "telescope") if not status_ok then - return + return end -- telescope.load_extension('media_files') -local actions = require "telescope.actions" +local actions = require("telescope.actions") -telescope.setup { - defaults = { +telescope.setup({ + defaults = { - prompt_prefix = " ", - selection_caret = " ", - path_display = { "smart" }, + prompt_prefix = " ", + selection_caret = " ", + path_display = { "smart" }, - mappings = { - i = { - [""] = actions.cycle_history_next, - [""] = actions.cycle_history_prev, - - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - - [""] = actions.close, - - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - - [""] = actions.select_default, - [""] = actions.select_horizontal, - [""] = actions.select_vertical, - [""] = actions.select_tab, - - [""] = actions.preview_scrolling_up, - [""] = actions.preview_scrolling_down, - - [""] = actions.results_scrolling_up, - [""] = actions.results_scrolling_down, - - [""] = actions.toggle_selection + actions.move_selection_worse, - [""] = actions.toggle_selection + actions.move_selection_better, - [""] = actions.send_to_qflist + actions.open_qflist, - [""] = actions.send_selected_to_qflist + actions.open_qflist, - [""] = actions.complete_tag, - [""] = actions.which_key, -- keys from pressing - }, - - n = { - [""] = actions.close, - [""] = actions.select_default, - [""] = actions.select_horizontal, - [""] = actions.select_vertical, - [""] = actions.select_tab, - - [""] = actions.toggle_selection + actions.move_selection_worse, - [""] = actions.toggle_selection + actions.move_selection_better, - [""] = actions.send_to_qflist + actions.open_qflist, - [""] = actions.send_selected_to_qflist + actions.open_qflist, - - ["j"] = actions.move_selection_next, - ["k"] = actions.move_selection_previous, - ["H"] = actions.move_to_top, - ["M"] = actions.move_to_middle, - ["L"] = actions.move_to_bottom, - - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - ["gg"] = actions.move_to_top, - ["G"] = actions.move_to_bottom, - - [""] = actions.preview_scrolling_up, - [""] = actions.preview_scrolling_down, - - [""] = actions.results_scrolling_up, - [""] = actions.results_scrolling_down, - - ["?"] = actions.which_key, - }, - }, - }, - pickers = { - -- Default configuration for builtin pickers goes here: - -- picker_name = { - -- picker_config_key = value, - -- ... - -- } - -- Now the picker_config_key will be applied every time you call this - -- builtin picker - }, - extensions = { - -- media_files = { - -- -- filetypes whitelist - -- -- defaults to {"png", "jpg", "mp4", "webm", "pdf"} - -- filetypes = {"png", "webp", "jpg", "jpeg"}, - -- find_cmd = "rg" -- find command (defaults to `fd`) - -- } - -- Your extension configuration goes here: - -- extension_name = { - -- extension_config_key = value, - -- } - -- please take a look at the readme of the extension you want to configure - }, -} + mappings = { + i = { + [""] = actions.cycle_history_next, + [""] = actions.cycle_history_prev, + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = actions.close, + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = actions.select_default, + [""] = actions.select_horizontal, + [""] = actions.select_vertical, + [""] = actions.select_tab, + [""] = actions.preview_scrolling_up, + [""] = actions.preview_scrolling_down, + [""] = actions.results_scrolling_up, + [""] = actions.results_scrolling_down, + [""] = actions.toggle_selection + actions.move_selection_worse, + [""] = actions.toggle_selection + actions.move_selection_better, + [""] = actions.send_to_qflist + actions.open_qflist, + [""] = actions.send_selected_to_qflist + actions.open_qflist, + [""] = actions.complete_tag, + [""] = actions.which_key, -- keys from pressing + }, + n = { + [""] = actions.close, + [""] = actions.select_default, + [""] = actions.select_horizontal, + [""] = actions.select_vertical, + [""] = actions.select_tab, + [""] = actions.toggle_selection + actions.move_selection_worse, + [""] = actions.toggle_selection + actions.move_selection_better, + [""] = actions.send_to_qflist + actions.open_qflist, + [""] = actions.send_selected_to_qflist + actions.open_qflist, + ["j"] = actions.move_selection_next, + ["k"] = actions.move_selection_previous, + ["H"] = actions.move_to_top, + ["M"] = actions.move_to_middle, + ["L"] = actions.move_to_bottom, + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + ["gg"] = actions.move_to_top, + ["G"] = actions.move_to_bottom, + [""] = actions.preview_scrolling_up, + [""] = actions.preview_scrolling_down, + [""] = actions.results_scrolling_up, + [""] = actions.results_scrolling_down, + ["?"] = actions.which_key, + }, + }, + }, + pickers = { + -- Default configuration for builtin pickers goes here: + -- picker_name = { + -- picker_config_key = value, + -- ... + -- } + -- Now the picker_config_key will be applied every time you call this + -- builtin picker + }, + extensions = { + -- media_files = { + -- -- filetypes whitelist + -- -- defaults to {"png", "jpg", "mp4", "webm", "pdf"} + -- filetypes = {"png", "webp", "jpg", "jpeg"}, + -- find_cmd = "rg" -- find command (defaults to `fd`) + -- } + -- Your extension configuration goes here: + -- extension_name = { + -- extension_config_key = value, + -- } + -- please take a look at the readme of the extension you want to configure + }, +}) diff --git a/nvim/lua/nvim/treesitter.lua b/nvim/lua/nvim/treesitter.lua index edf8283..575ecef 100644 --- a/nvim/lua/nvim/treesitter.lua +++ b/nvim/lua/nvim/treesitter.lua @@ -1,14 +1,14 @@ local configs = require("nvim-treesitter.configs") -configs.setup { - ensure_installed = "all", - sync_install = false, - ignore_install = { "" }, -- List of parsers to ignore installing - highlight = { - enable = true, -- false will disable the whole extension - disable = { "" }, -- list of language that will be disabled - additional_vim_regex_highlighting = true, - }, - indent = { enable = true, disable = { "yaml" } }, +configs.setup({ + ensure_installed = "all", + sync_install = false, + ignore_install = { "" }, -- List of parsers to ignore installing + highlight = { + enable = true, -- false will disable the whole extension + disable = { "" }, -- list of language that will be disabled + additional_vim_regex_highlighting = true, + }, + indent = { enable = true, disable = { "yaml" } }, rainbow = { enable = true, extended_mode = true, @@ -18,7 +18,7 @@ configs.setup { enable = true, enable_autocmd = false, }, -} +}) vim.cmd("hi rainbowcol1 guifg=#FFFFFF") vim.cmd("hi rainbowcol2 guifg=#00FF00") vim.cmd("hi rainbowcol3 guifg=#2244FF") -- 2.30.2