diff options
| author | Aleksa Vuckovic <aleksa@vuckovic.cc> | 2023-02-24 03:54:38 +0100 |
|---|---|---|
| committer | Aleksa Vuckovic <aleksa@vuckovic.cc> | 2023-02-24 03:54:38 +0100 |
| commit | bbe5d2d967a1a77328c71e11823bb57d56ee044c (patch) | |
| tree | 1ad4f5ed0ecfd9bce0cc497a0be59ea9cad094fd | |
| parent | 0703660d49f22376d52a969e8c3cca64480b0f1b (diff) | |
formatting
| -rw-r--r-- | lua/user/autopairs.lua | 40 | ||||
| -rw-r--r-- | lua/user/bufferline.lua | 134 | ||||
| -rw-r--r-- | lua/user/cmp.lua | 222 | ||||
| -rw-r--r-- | lua/user/lsp/ccls.lua | 72 | ||||
| -rw-r--r-- | lua/user/lsp/handlers.lua | 140 | ||||
| -rw-r--r-- | lua/user/lsp/init.lua | 2 | ||||
| -rw-r--r-- | lua/user/lsp/mason.lua | 32 | ||||
| -rw-r--r-- | lua/user/nvim-tree.lua | 154 | ||||
| -rw-r--r-- | lua/user/options.lua | 74 | ||||
| -rw-r--r-- | lua/user/plugins.lua | 77 |
10 files changed, 475 insertions, 472 deletions
diff --git a/lua/user/autopairs.lua b/lua/user/autopairs.lua index 4a3b9a7..be94c26 100644 --- a/lua/user/autopairs.lua +++ b/lua/user/autopairs.lua @@ -1,33 +1,33 @@ -- Setup nvim-cmp. local status_ok, npairs = pcall(require, "nvim-autopairs") if not status_ok then - return + return end npairs.setup { - check_ts = true, - ts_config = { - lua = { "string", "source" }, - javascript = { "string", "template_string" }, - java = false, - }, - disable_filetype = { "TelescopePrompt", "spectre_panel" }, - fast_wrap = { - map = "<M-e>", - chars = { "{", "[", "(", '"', "'" }, - pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), - offset = 0, -- Offset from pattern match - end_key = "$", - keys = "qwertyuiopzxcvbnmasdfghjkl", - check_comma = true, - highlight = "PmenuSel", - highlight_grey = "LineNr", - }, + check_ts = true, + ts_config = { + lua = { "string", "source" }, + javascript = { "string", "template_string" }, + java = false, + }, + disable_filetype = { "TelescopePrompt", "spectre_panel" }, + fast_wrap = { + map = "<M-e>", + chars = { "{", "[", "(", '"', "'" }, + pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), + offset = 0, -- Offset from pattern match + end_key = "$", + keys = "qwertyuiopzxcvbnmasdfghjkl", + check_comma = true, + highlight = "PmenuSel", + highlight_grey = "LineNr", + }, } 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 = "" } }) diff --git a/lua/user/bufferline.lua b/lua/user/bufferline.lua index 0b5cbf5..95464ee 100644 --- a/lua/user/bufferline.lua +++ b/lua/user/bufferline.lua @@ -1,73 +1,73 @@ local status_ok, bufferline = pcall(require, "bufferline") if not status_ok then - return + return end bufferline.setup { - options = { - numbers = "none", -- | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string, - close_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" - right_mouse_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" - left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions" - middle_mouse_command = nil, -- can be a string | function, see "Mouse actions" - -- NOTE: this plugin is designed with this icon in mind, - -- and so changing this is NOT recommended, this is intended - -- as an escape hatch for people who cannot bear it for whatever reason - buffer_close_icon = "", - -- buffer_close_icon = '', - modified_icon = "●", - close_icon = "", - -- close_icon = '', - left_trunc_marker = "", - right_trunc_marker = "", - --- name_formatter can be used to change the buffer's label in the bufferline. - --- Please note some names can/will break the - --- bufferline so use this at your discretion knowing that it has - --- some limitations that will *NOT* be fixed. - -- name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr" - -- -- remove extension from markdown files for example - -- if buf.name:match('%.md') then - -- return vim.fn.fnamemodify(buf.name, ':t:r') - -- end - -- end, - max_name_length = 30, - max_prefix_length = 30, -- prefix used when a buffer is de-duplicated - tab_size = 21, - diagnostics = false, -- | "nvim_lsp" | "coc", - diagnostics_update_in_insert = false, - -- diagnostics_indicator = function(count, level, diagnostics_dict, context) - -- return "("..count..")" - -- end, - -- NOTE: this will be called a lot so don't do any heavy processing here - -- custom_filter = function(buf_number) - -- -- filter out filetypes you don't want to see - -- if vim.bo[buf_number].filetype ~= "<i-dont-want-to-see-this>" then - -- return true - -- end - -- -- filter out by buffer name - -- if vim.fn.bufname(buf_number) ~= "<buffer-name-I-dont-want>" then - -- return true - -- end - -- -- filter out based on arbitrary rules - -- -- e.g. filter out vim wiki buffer from tabline in your work repo - -- if vim.fn.getcwd() == "<work-repo>" and vim.bo[buf_number].filetype ~= "wiki" then - -- return true - -- end - -- end, - offsets = { { filetype = "NvimTree", text = "", padding = 1 } }, - show_buffer_icons = true, - show_buffer_close_icons = true, - show_close_icon = true, - show_tab_indicators = true, - persist_buffer_sort = true, -- whether or not custom sorted buffers should persist - -- can also be a table containing 2 custom separators - -- [focused and unfocused]. eg: { '|', '|' } - separator_style = "thin", -- | "thick" | "thin" | { 'any', 'any' }, - enforce_regular_tabs = true, - always_show_bufferline = true, - -- sort_by = 'id' | 'extension' | 'relative_directory' | 'directory' | 'tabs' | function(buffer_a, buffer_b) - -- -- add custom logic - -- return buffer_a.modified > buffer_b.modified - -- end - }, + options = { + numbers = "none", -- | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string, + close_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" + right_mouse_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" + left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions" + middle_mouse_command = nil, -- can be a string | function, see "Mouse actions" + -- NOTE: this plugin is designed with this icon in mind, + -- and so changing this is NOT recommended, this is intended + -- as an escape hatch for people who cannot bear it for whatever reason + buffer_close_icon = "", + -- buffer_close_icon = '', + modified_icon = "●", + close_icon = "", + -- close_icon = '', + left_trunc_marker = "", + right_trunc_marker = "", + --- name_formatter can be used to change the buffer's label in the bufferline. + --- Please note some names can/will break the + --- bufferline so use this at your discretion knowing that it has + --- some limitations that will *NOT* be fixed. + -- name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr" + -- -- remove extension from markdown files for example + -- if buf.name:match('%.md') then + -- return vim.fn.fnamemodify(buf.name, ':t:r') + -- end + -- end, + max_name_length = 30, + max_prefix_length = 30, -- prefix used when a buffer is de-duplicated + tab_size = 21, + diagnostics = false, -- | "nvim_lsp" | "coc", + diagnostics_update_in_insert = false, + -- diagnostics_indicator = function(count, level, diagnostics_dict, context) + -- return "("..count..")" + -- end, + -- NOTE: this will be called a lot so don't do any heavy processing here + -- custom_filter = function(buf_number) + -- -- filter out filetypes you don't want to see + -- if vim.bo[buf_number].filetype ~= "<i-dont-want-to-see-this>" then + -- return true + -- end + -- -- filter out by buffer name + -- if vim.fn.bufname(buf_number) ~= "<buffer-name-I-dont-want>" then + -- return true + -- end + -- -- filter out based on arbitrary rules + -- -- e.g. filter out vim wiki buffer from tabline in your work repo + -- if vim.fn.getcwd() == "<work-repo>" and vim.bo[buf_number].filetype ~= "wiki" then + -- return true + -- end + -- end, + offsets = { { filetype = "NvimTree", text = "", padding = 1 } }, + show_buffer_icons = true, + show_buffer_close_icons = true, + show_close_icon = true, + show_tab_indicators = true, + persist_buffer_sort = true, -- whether or not custom sorted buffers should persist + -- can also be a table containing 2 custom separators + -- [focused and unfocused]. eg: { '|', '|' } + separator_style = "thin", -- | "thick" | "thin" | { 'any', 'any' }, + enforce_regular_tabs = true, + always_show_bufferline = true, + -- sort_by = 'id' | 'extension' | 'relative_directory' | 'directory' | 'tabs' | function(buffer_a, buffer_b) + -- -- add custom logic + -- return buffer_a.modified > buffer_b.modified + -- end + }, } diff --git a/lua/user/cmp.lua b/lua/user/cmp.lua index 942dd3f..39bde60 100644 --- a/lua/user/cmp.lua +++ b/lua/user/cmp.lua @@ -1,130 +1,130 @@ local cmp_status_ok, cmp = pcall(require, "cmp") if not cmp_status_ok then - return + return end local snip_status_ok, luasnip = pcall(require, "luasnip") if not snip_status_ok then - return + return end 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 = "", } -- find more here: https://www.nerdfonts.com/cheat-sheet cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) -- For `luasnip` users. - end, - }, - mapping = { - ["<C-k>"] = cmp.mapping.select_prev_item(), - ["<C-j>"] = cmp.mapping.select_next_item(), - ["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), - ["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), - ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), - ["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping. - ["<C-e>"] = cmp.mapping { - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }, - -- Accept currently selected item. If none selected, `select` first item. - -- Set `select` to `false` to only confirm explicitly selected items. - ["<CR>"] = cmp.mapping.confirm { select = true }, - ["<Tab>"] = 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", - }), - ["<S-Tab>"] = 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" }, - format = function(entry, vim_item) - -- Kind icons - vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) - -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind - vim_item.menu = ({ - nvim_lsp = "[LSP]", - luasnip = "[Snippet]", - buffer = "[Buffer]", - path = "[Path]", - nvim_lua = "[NVIM_LUA]", - })[entry.source.name] - return vim_item - end, - }, - sources = { - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "buffer" }, - { name = "path" }, - { name = "nvim_lua" }, - }, - confirm_opts = { - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }, - native = { - border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, - }, - experimental = { - ghost_text = true, - native_menu = false, - }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = { + ["<C-k>"] = cmp.mapping.select_prev_item(), + ["<C-j>"] = cmp.mapping.select_next_item(), + ["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs( -1), { "i", "c" }), + ["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), + ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + ["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping. + ["<C-e>"] = cmp.mapping { + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }, + -- Accept currently selected item. If none selected, `select` first item. + -- Set `select` to `false` to only confirm explicitly selected items. + ["<CR>"] = cmp.mapping.confirm { select = true }, + ["<Tab>"] = 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", + }), + ["<S-Tab>"] = 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" }, + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind + vim_item.menu = ({ + nvim_lsp = "[LSP]", + luasnip = "[Snippet]", + buffer = "[Buffer]", + path = "[Path]", + nvim_lua = "[NVIM_LUA]", + })[entry.source.name] + return vim_item + end, + }, + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + { name = "nvim_lua" }, + }, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + native = { + border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + }, + experimental = { + ghost_text = true, + native_menu = false, + }, } diff --git a/lua/user/lsp/ccls.lua b/lua/user/lsp/ccls.lua index 94fe2a0..b3393da 100644 --- a/lua/user/lsp/ccls.lua +++ b/lua/user/lsp/ccls.lua @@ -1,58 +1,58 @@ local status, lspconfig = pcall(require, "lspconfig") if not status then - return + return end vim.notify(vim.fn.expand('%:p')); local extraArgs_opt = {}; -if string.match(vim.fn.expand('%:p'),"/home/aleksa/mygit/benet.rs/") then - vim.opt["shiftwidth"]=2; - vim.opt["tabstop"]=2; - vim.opt["expandtab"]=true; - vim.notify("jsx"); +if string.match(vim.fn.expand('%:p'), "/home/aleksa/mygit/benet.rs/") then + vim.opt["shiftwidth"] = 2; + vim.opt["tabstop"] = 2; + vim.opt["expandtab"] = true; + vim.notify("jsx"); end -if string.match(vim.fn.expand('%:p'),"/home/aleksa/mygit/oldrepos/mykernel/") then - extraArgs_opt = { "--sysroot=/opt/aleksa", "--gcc-toolchain=/opt/aleksa/usr/bin/i686-aleksa-gcc", }; - vim.notify("mykernel"); +if string.match(vim.fn.expand('%:p'), "/home/aleksa/mygit/oldrepos/mykernel/") then + extraArgs_opt = { "--sysroot=/opt/aleksa", "--gcc-toolchain=/opt/aleksa/usr/bin/i686-aleksa-gcc", }; + vim.notify("mykernel"); end -if string.match(vim.fn.expand('%:p'),"/media/linux/") then - extraArgs_opt = { "--sysroot=/media/linux/staging/", }; - vim.notify("linux"); +if string.match(vim.fn.expand('%:p'), "/media/linux/") then + extraArgs_opt = { "--sysroot=/media/linux/staging/", }; + vim.notify("linux"); end -if string.match(vim.fn.expand('%:p'),"/home/aleksa/files/arduino_avr") then - extraArgs_opt = { "--sysroot=/usr/avr", }; - vim.notify("arduino-avr"); +if string.match(vim.fn.expand('%:p'), "/home/aleksa/files/arduino_avr") then + extraArgs_opt = { "--sysroot=/usr/avr", }; + vim.notify("arduino-avr"); end -if string.match(vim.fn.expand('%:p'),"/home/aleksa/mygit/mykernel64") then - extraArgs_opt = { "--sysroot=/home/aleksa/mygit/mykernel64/kernel", }; - vim.notify("mykernel64"); +if string.match(vim.fn.expand('%:p'), "/home/aleksa/mygit/mykernel64") then + extraArgs_opt = { "--sysroot=/home/aleksa/mygit/mykernel64/kernel", }; + vim.notify("mykernel64"); end lspconfig.ccls.setup { - on_attach = require("user.lsp.handlers").on_attach, - capabilities = require("user.lsp.handlers").capabilities, - - flags = { - debounce_text_changes = 150, - }; - init_options = { - cache = { - directory = "/tmp/ccls-cache"; - }; - index = { - threads = 0; - }; - clang = { - excludeArgs = { "-frounding-math"}; - extraArgs = extraArgs_opt; - } - }; + on_attach = require("user.lsp.handlers").on_attach, + capabilities = require("user.lsp.handlers").capabilities, + + flags = { + debounce_text_changes = 150, + }, + init_options = { + cache = { + directory = "/tmp/ccls-cache", + }, + index = { + threads = 0, + }, + clang = { + excludeArgs = { "-frounding-math" }, + extraArgs = extraArgs_opt, + } + }, } diff --git a/lua/user/lsp/handlers.lua b/lua/user/lsp/handlers.lua index b741928..ee802b9 100644 --- a/lua/user/lsp/handlers.lua +++ b/lua/user/lsp/handlers.lua @@ -1,101 +1,103 @@ local M = {} M.setup = function() - local signs = { - { name = "DiagnosticSignError", text = "" }, - { name = "DiagnosticSignWarn", text = "" }, - { name = "DiagnosticSignHint", text = "" }, - { name = "DiagnosticSignInfo", text = "" }, - } + 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 + 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_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 = "", - }, - } + 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.diagnostic.config(config) + vim.diagnostic.config(config) - vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { - 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", - }) + 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.server_capabilities.document_highlight then - vim.api.nvim_exec( - [[ + -- Set autocommands conditional on server_capabilities + if client.server_capabilities.document_highlight then + vim.api.nvim_exec( + [[ augroup lsp_document_highlight autocmd! * <buffer> autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight() autocmd CursorMoved <buffer> 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", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts) - vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts) - vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts) - vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) - vim.api.nvim_buf_set_keymap(bufnr, "n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts) - vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.rename()<CR>", opts) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>f", "<cmd>lua vim.diagnostic.open_float()<CR>", opts) - vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", '<cmd>lua vim.diagnostic.goto_prev({ border = "rounded" })<CR>', opts) - vim.api.nvim_buf_set_keymap( - bufnr, - "n", - "gl", - '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics({ border = "rounded" })<CR>', - opts - ) - vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", '<cmd>lua vim.diagnostic.goto_next({ border = "rounded" })<CR>', opts) - vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", 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", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.rename()<CR>", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>f", "<cmd>lua vim.diagnostic.open_float()<CR>", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", '<cmd>lua vim.diagnostic.goto_prev({ border = "rounded" })<CR>', + opts) + vim.api.nvim_buf_set_keymap( + bufnr, + "n", + "gl", + '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics({ border = "rounded" })<CR>', + opts + ) + vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", '<cmd>lua vim.diagnostic.goto_next({ border = "rounded" })<CR>', + opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts) + vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]] end M.on_attach = function(client, bufnr) - if client.name == "tsserver" then - client.server_capabilities.document_formatting = false - end - lsp_keymaps(bufnr) - lsp_highlight_document(client) + if client.name == "tsserver" then + client.server_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.default_capabilities(capabilities) diff --git a/lua/user/lsp/init.lua b/lua/user/lsp/init.lua index 202cccb..4ac9a3e 100644 --- a/lua/user/lsp/init.lua +++ b/lua/user/lsp/init.lua @@ -2,7 +2,7 @@ require "user.lsp.mason" local status, lspconfig = pcall(require, "lspconfig") if not status then - return + return end require "user.lsp.ccls" diff --git a/lua/user/lsp/mason.lua b/lua/user/lsp/mason.lua index 1b5717d..2c14313 100644 --- a/lua/user/lsp/mason.lua +++ b/lua/user/lsp/mason.lua @@ -1,43 +1,43 @@ local status, mason = pcall(require, "mason") if not status then - return + return end -- mason mason.setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - } - } + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + } + } }) -- mason-lspconfig require("mason-lspconfig").setup { - ensure_installed = { "pylsp", "bashls", "lua_ls", "cmake" }, + ensure_installed = { "pylsp", "bashls", "lua_ls", "cmake" }, } require("mason-lspconfig").setup_handlers { - function (server_name) + function(server_name) require("lspconfig")[server_name].setup {} end } -- mason-null-ls require('mason-null-ls').setup({ - automatic_setup = true, - ensure_installed = { "cpplint" } + automatic_setup = true, + ensure_installed = {} }) require('mason-null-ls').setup_handlers { - function(source_name, methods) - require("mason-null-ls.automatic_setup")(source_name, methods) - end, + function(source_name, methods) + require("mason-null-ls.automatic_setup")(source_name, methods) + end, } -- null_ls local status, null_ls = pcall(require, "null-ls") if not status then - return + return end null_ls.setup() diff --git a/lua/user/nvim-tree.lua b/lua/user/nvim-tree.lua index ec7cb70..932cbbe 100644 --- a/lua/user/nvim-tree.lua +++ b/lua/user/nvim-tree.lua @@ -3,90 +3,90 @@ local status_ok, nvim_tree = pcall(require, "nvim-tree") if not status_ok then - return + return end local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") if not config_status_ok then - return + return end local tree_cb = nvim_tree_config.nvim_tree_callback nvim_tree.setup { - disable_netrw = true, - hijack_netrw = true, - open_on_tab = false, - 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, - hide_root_folder = false, - side = "left", - mappings = { - custom_only = false, - list = { - { key = { "l", "<CR>", "o" }, cb = tree_cb "edit" }, - { key = "h", cb = tree_cb "close_node" }, - { key = "v", cb = tree_cb "vsplit" }, - }, - }, - number = false, - relativenumber = false, - }, - trash = { - cmd = "trash", - require_confirm = true, - }, - renderer = { - icons = { - glyphs = { - default = "", - symlink = "", - git = { - unstaged = "", - staged = "S", - unmerged = "", - renamed = "➜", - deleted = "", - untracked = "U", - ignored = "◌", - }, - folder = { - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", - }, - }, - } - } + disable_netrw = true, + hijack_netrw = true, + open_on_tab = false, + 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, + hide_root_folder = false, + side = "left", + mappings = { + custom_only = false, + list = { + { key = { "l", "<CR>", "o" }, cb = tree_cb "edit" }, + { key = "h", cb = tree_cb "close_node" }, + { key = "v", cb = tree_cb "vsplit" }, + }, + }, + number = false, + relativenumber = false, + }, + trash = { + cmd = "trash", + require_confirm = true, + }, + renderer = { + icons = { + glyphs = { + default = "", + symlink = "", + git = { + unstaged = "", + staged = "S", + unmerged = "", + renamed = "➜", + deleted = "", + untracked = "U", + ignored = "◌", + }, + folder = { + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + }, + }, + } + } } diff --git a/lua/user/options.lua b/lua/user/options.lua index a24db50..5a0433c 100644 --- a/lua/user/options.lua +++ b/lua/user/options.lua @@ -1,46 +1,46 @@ 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 - completeopt = { "menuone", "noselect" }, -- mostly just for cmp - conceallevel = 0, -- so that `` is visible in markdown files - fileencoding = "utf-8", -- the encoding written to a fie - 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 = 100, -- 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 = false, -- convert tabs to spaces - shiftwidth = 8, -- the number of spaces inserted for each indentation - tabstop = 8, -- insert 4 spaces for a tab - preserveindent = true, - softtabstop = 0, - 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 + 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 + completeopt = { "menuone", "noselect" }, -- mostly just for cmp + conceallevel = 0, -- so that `` is visible in markdown files + fileencoding = "utf-8", -- the encoding written to a fie + 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 = 100, -- 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 = false, -- convert tabs to spaces + shiftwidth = 8, -- the number of spaces inserted for each indentation + tabstop = 8, -- insert 4 spaces for a tab + preserveindent = true, + softtabstop = 0, + 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 } vim.opt.shortmess:append "c" for k, v in pairs(options) do - vim.opt[k] = v + vim.opt[k] = v end -- vim.cmd "set whichwrap+=<,>,[,],h,l" diff --git a/lua/user/plugins.lua b/lua/user/plugins.lua index a3fd1f2..3129e1b 100644 --- a/lua/user/plugins.lua +++ b/lua/user/plugins.lua @@ -1,8 +1,9 @@ local fn = vim.fn -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}) - vim.cmd [[packadd packer.nvim]] + packer_bootstrap = fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", + install_path }) + vim.cmd [[packadd packer.nvim]] end -- Autocommand that reloads neovim whenever you save the plugins.lua file @@ -15,51 +16,51 @@ vim.cmd([[ local status, packer = pcall(require, "packer") if not status then - return + return end packer.init { - display = { - open_fn = function() - return require("packer.util").float { border = "rounded" } - end, - }, + display = { + open_fn = function() + return require("packer.util").float { border = "rounded" } + end, + }, } return packer.startup(function(use) --- Packer - use "wbthomason/packer.nvim" + -- Packer + use "wbthomason/packer.nvim" --- cmp - use "hrsh7th/nvim-cmp" - use "saadparwaiz1/cmp_luasnip" - use "hrsh7th/cmp-nvim-lsp" - use "hrsh7th/cmp-buffer" - use "hrsh7th/cmp-path" - use "hrsh7th/cmp-cmdline" - use "hrsh7th/cmp-nvim-lua" + -- cmp + use "hrsh7th/nvim-cmp" + use "saadparwaiz1/cmp_luasnip" + use "hrsh7th/cmp-nvim-lsp" + use "hrsh7th/cmp-buffer" + use "hrsh7th/cmp-path" + use "hrsh7th/cmp-cmdline" + use "hrsh7th/cmp-nvim-lua" --- LSP, linters & formatters - use "neovim/nvim-lspconfig" - use "williamboman/mason.nvim" - use "williamboman/mason-lspconfig.nvim" - use "nvim-lua/plenary.nvim" - use "jose-elias-alvarez/null-ls.nvim" - use "jay-babu/mason-null-ls.nvim" + -- LSP, linters & formatters + use "neovim/nvim-lspconfig" + use "williamboman/mason.nvim" + use "williamboman/mason-lspconfig.nvim" + use "nvim-lua/plenary.nvim" + use "jose-elias-alvarez/null-ls.nvim" + use "jay-babu/mason-null-ls.nvim" --- Colorsheme - use "morhetz/gruvbox" + -- Colorsheme + use "morhetz/gruvbox" --- Other - use "windwp/nvim-autopairs" - use "kyazdani42/nvim-web-devicons" - use "kyazdani42/nvim-tree.lua" - use "akinsho/bufferline.nvim" + -- Other + use "windwp/nvim-autopairs" + use "kyazdani42/nvim-web-devicons" + use "kyazdani42/nvim-tree.lua" + use "akinsho/bufferline.nvim" - -- 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 + -- 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) |
