From 6c1c6ba2f5b45c0c3ba178ee34a9992ce23b7180 Mon Sep 17 00:00:00 2001 From: Aleksa Vučković Date: Wed, 5 Jan 2022 15:35:38 +0100 Subject: ccls working as intended --- lua/cmp.lua | 35 ----------- lua/cmp1.lua | 14 ----- lua/keymaps.lua | 68 -------------------- lua/lsp/init.lua | 0 lua/options.lua | 51 --------------- lua/plugins.lua | 57 ----------------- lua/user/cmp.lua | 130 +++++++++++++++++++++++++++++++++++++++ lua/user/keymaps.lua | 68 ++++++++++++++++++++ lua/user/lsp/handlers.lua | 104 +++++++++++++++++++++++++++++++ lua/user/lsp/init.lua | 9 +++ lua/user/lsp/lsp-installer.lua | 28 +++++++++ lua/user/lsp/settings/bashls.lua | 0 lua/user/lsp/settings/ccls.lua | 34 ++++++++++ lua/user/lsp/settings/texlab.lua | 0 lua/user/options.lua | 51 +++++++++++++++ lua/user/plugins.lua | 59 ++++++++++++++++++ 16 files changed, 483 insertions(+), 225 deletions(-) delete mode 100644 lua/cmp.lua delete mode 100644 lua/cmp1.lua delete mode 100644 lua/keymaps.lua delete mode 100644 lua/lsp/init.lua delete mode 100644 lua/options.lua delete mode 100644 lua/plugins.lua create mode 100644 lua/user/cmp.lua create mode 100644 lua/user/keymaps.lua create mode 100644 lua/user/lsp/handlers.lua create mode 100644 lua/user/lsp/init.lua create mode 100644 lua/user/lsp/lsp-installer.lua create mode 100644 lua/user/lsp/settings/bashls.lua create mode 100644 lua/user/lsp/settings/ccls.lua create mode 100644 lua/user/lsp/settings/texlab.lua create mode 100644 lua/user/options.lua create mode 100644 lua/user/plugins.lua (limited to 'lua') diff --git a/lua/cmp.lua b/lua/cmp.lua deleted file mode 100644 index ec6695f..0000000 --- a/lua/cmp.lua +++ /dev/null @@ -1,35 +0,0 @@ -local status, cmp = pcall(require, "cmp") -if not status then - return -end - -local status, luasnip = pcall(require, "luasnip") -if not status then - return -end - - -cmp.setup({ - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = { - [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), - [''] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. - [''] = cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }), - [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - }, - sources = { --- { name = 'nvim_lsp' }, --- { name = 'luasnip' }, --- { name = 'buffer' }, --- { name = "path" }, - }, -}) diff --git a/lua/cmp1.lua b/lua/cmp1.lua deleted file mode 100644 index 092402c..0000000 --- a/lua/cmp1.lua +++ /dev/null @@ -1,14 +0,0 @@ - config = function () - require'cmp'.setup { - snippet = { - expand = function(args) - require'luasnip'.lsp_expand(args.body) - end - }, - - sources = { - { name = 'luasnip' }, - -- more sources - }, - } - end diff --git a/lua/keymaps.lua b/lua/keymaps.lua deleted file mode 100644 index be9bb45..0000000 --- a/lua/keymaps.lua +++ /dev/null @@ -1,68 +0,0 @@ -local opts = { noremap = true, silent = true } - -local term_opts = { silent = true } - --- Shorten function name -local keymap = vim.api.nvim_set_keymap - ---Remap space as leader key -keymap("", "", "", opts) -vim.g.mapleader = " " -vim.g.maplocalleader = " " - --- Modes --- normal_mode = "n", --- insert_mode = "i", --- visual_mode = "v", --- visual_block_mode = "x", --- term_mode = "t", --- command_mode = "c", - --- Normal -- --- Better window navigation -keymap("n", "", "h", opts) -keymap("n", "", "j", opts) -keymap("n", "", "k", opts) -keymap("n", "", "l", opts) - --- Resize with arrows -keymap("n", "", ":resize -2", opts) -keymap("n", "", ":resize +2", opts) -keymap("n", "", ":vertical resize -2", opts) -keymap("n", "", ":vertical resize +2", opts) - --- Navigate buffers -keymap("n", "", ":bnext", opts) -keymap("n", "", ":bprevious", opts) - --- Move text up and down -keymap("n", "", ":m .+1==gi", opts) -keymap("n", "", ":m .-2==gi", opts) - --- Insert -- --- Press jk fast to enter --- keymap("i", "jk", "", opts) - --- Visual -- --- Stay in indent mode -keymap("v", "<", "", ">gv", opts) - --- Move text up and down -keymap("v", "", ":m .+1==", opts) -keymap("v", "", ":m .-2==", opts) -keymap("v", "p", '"_dP', opts) - --- Visual Block -- --- Move text up and down -keymap("x", "J", ":move '>+1gv-gv", opts) -keymap("x", "K", ":move '<-2gv-gv", opts) -keymap("x", "", ":move '>+1gv-gv", opts) -keymap("x", "", ":move '<-2gv-gv", opts) - --- Terminal -- --- Better terminal navigation --- keymap("t", "", "h", term_opts) --- keymap("t", "", "j", term_opts) --- keymap("t", "", "k", term_opts) --- keymap("t", "", "l", term_opts) diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua deleted file mode 100644 index e69de29..0000000 diff --git a/lua/options.lua b/lua/options.lua deleted file mode 100644 index a15e0e4..0000000 --- a/lua/options.lua +++ /dev/null @@ -1,51 +0,0 @@ -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 = true, -- convert tabs to spaces - shiftwidth = 4, -- the number of spaces inserted for each indentation - tabstop = 4, -- 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 -end - --- vim.cmd "set whichwrap+=<,>,[,],h,l" -vim.cmd [[set iskeyword+=-]] -vim.cmd [[set formatoptions-=cro]] -- TODO: this doesn't seem to work - --- Open a file from its last left off position -vim.cmd [[ au BufReadPost * if expand('%:p') !~# '\m/\.git/' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif ]] diff --git a/lua/plugins.lua b/lua/plugins.lua deleted file mode 100644 index 3f7c1e8..0000000 --- a/lua/plugins.lua +++ /dev/null @@ -1,57 +0,0 @@ -local fn = vim.fn -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}) -end - -vim.cmd([[ - augroup packer_user_config - autocmd! - autocmd BufWritePost plugins.lua source | PackerSync - augroup end -]]) - -local status, packer = pcall(require, "packer") -if not status then - return -end - -packer.init { - display = { - open_fn = function() - return require("packer.util").float { border = "rounded" } - end, - }, -} - -return packer.startup(function(use) --- 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" - --- snippets - use "L3MON4D3/LuaSnip" - --- LSP - use "neovim/nvim-lspconfig" - use "williamboman/nvim-lsp-installer" - --- Other - 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 -end) diff --git a/lua/user/cmp.lua b/lua/user/cmp.lua new file mode 100644 index 0000000..5a005e8 --- /dev/null +++ b/lua/user/cmp.lua @@ -0,0 +1,130 @@ +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end + +local snip_status_ok, luasnip = pcall(require, "luasnip") +if not snip_status_ok then + return +end + + +local check_backspace = function() + 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 = "", +} +-- 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 = { + [""] = 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.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. + [""] = 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. + [""] = cmp.mapping.confirm { select = true }, + [""] = 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" }, + 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, + }, + documentation = { + border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + }, + experimental = { + ghost_text = false, + native_menu = false, + }, +} diff --git a/lua/user/keymaps.lua b/lua/user/keymaps.lua new file mode 100644 index 0000000..be9bb45 --- /dev/null +++ b/lua/user/keymaps.lua @@ -0,0 +1,68 @@ +local opts = { noremap = true, silent = true } + +local term_opts = { silent = true } + +-- Shorten function name +local keymap = vim.api.nvim_set_keymap + +--Remap space as leader key +keymap("", "", "", opts) +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +-- Modes +-- normal_mode = "n", +-- insert_mode = "i", +-- visual_mode = "v", +-- visual_block_mode = "x", +-- term_mode = "t", +-- command_mode = "c", + +-- Normal -- +-- Better window navigation +keymap("n", "", "h", opts) +keymap("n", "", "j", opts) +keymap("n", "", "k", opts) +keymap("n", "", "l", opts) + +-- Resize with arrows +keymap("n", "", ":resize -2", opts) +keymap("n", "", ":resize +2", opts) +keymap("n", "", ":vertical resize -2", opts) +keymap("n", "", ":vertical resize +2", opts) + +-- Navigate buffers +keymap("n", "", ":bnext", opts) +keymap("n", "", ":bprevious", opts) + +-- Move text up and down +keymap("n", "", ":m .+1==gi", opts) +keymap("n", "", ":m .-2==gi", opts) + +-- Insert -- +-- Press jk fast to enter +-- keymap("i", "jk", "", opts) + +-- Visual -- +-- Stay in indent mode +keymap("v", "<", "", ">gv", opts) + +-- Move text up and down +keymap("v", "", ":m .+1==", opts) +keymap("v", "", ":m .-2==", opts) +keymap("v", "p", '"_dP', opts) + +-- Visual Block -- +-- Move text up and down +keymap("x", "J", ":move '>+1gv-gv", opts) +keymap("x", "K", ":move '<-2gv-gv", opts) +keymap("x", "", ":move '>+1gv-gv", opts) +keymap("x", "", ":move '<-2gv-gv", opts) + +-- Terminal -- +-- Better terminal navigation +-- keymap("t", "", "h", term_opts) +-- keymap("t", "", "j", term_opts) +-- keymap("t", "", "k", term_opts) +-- keymap("t", "", "l", term_opts) diff --git a/lua/user/lsp/handlers.lua b/lua/user/lsp/handlers.lua new file mode 100644 index 0000000..76b4572 --- /dev/null +++ b/lua/user/lsp/handlers.lua @@ -0,0 +1,104 @@ +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 config = { + -- disable virtual text + virtual_text = false, + -- 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.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( + [[ + 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 +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()' ]] +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) +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 +end + +M.capabilities = cmp_nvim_lsp.update_capabilities(capabilities) + +return M diff --git a/lua/user/lsp/init.lua b/lua/user/lsp/init.lua new file mode 100644 index 0000000..c218647 --- /dev/null +++ b/lua/user/lsp/init.lua @@ -0,0 +1,9 @@ +local status_ok, _ = pcall(require, "lspconfig") +if not status_ok then + return +end + +require "user.lsp.lsp-installer" +require("user.lsp.handlers").setup() + +require "user.lsp.settings.ccls" diff --git a/lua/user/lsp/lsp-installer.lua b/lua/user/lsp/lsp-installer.lua new file mode 100644 index 0000000..18490ce --- /dev/null +++ b/lua/user/lsp/lsp-installer.lua @@ -0,0 +1,28 @@ +local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer") +if not status_ok then + 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("user.lsp.handlers").on_attach, + capabilities = require("user.lsp.handlers").capabilities, + } + + if server.name == "bashls" then + local bashls_opts = require("user.lsp.settings.bashls") + opts = vim.tbl_deep_extend("force", bashls_opts, opts) + end + + if server.name == "texlab" then + local texlab_opts = require("user.lsp.settings.texlab") + opts = vim.tbl_deep_extend("force", texlab_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) +end) diff --git a/lua/user/lsp/settings/bashls.lua b/lua/user/lsp/settings/bashls.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/user/lsp/settings/ccls.lua b/lua/user/lsp/settings/ccls.lua new file mode 100644 index 0000000..d663f7c --- /dev/null +++ b/lua/user/lsp/settings/ccls.lua @@ -0,0 +1,34 @@ +local status, lspconfig = pcall(require, "lspconfig") +if not status then + return +end + + +vim.notify(vim.fn.expand('%:p')); +local extraArgs_opt = {}; + +if string.match(vim.fn.expand('%:p'),"/home/aleksa/mygit/mykernel/") then + extraArgs_opt = { "--sysroot=/home/aleksa/mygit/mykernel/sysroot", "--gcc-toolchain=/usr/bin/i686-elf-gcc", "-ffreestanding", "-nobuiltininc"}; +else +end + + +lspconfig.ccls.setup { + on_attach = on_attach, + flags = { + debounce_text_changes = 150, + }; + init_options = { + compilationDatabaseDirectory = "build"; + cache = { + directory = "/tmp/ccls-cache"; + }; + index = { + threads = 0; + }; + clang = { + excludeArgs = { "-frounding-math"}; + extraArgs = extraArgs_opt; + } + }; +} diff --git a/lua/user/lsp/settings/texlab.lua b/lua/user/lsp/settings/texlab.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/user/options.lua b/lua/user/options.lua new file mode 100644 index 0000000..a15e0e4 --- /dev/null +++ b/lua/user/options.lua @@ -0,0 +1,51 @@ +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 = true, -- convert tabs to spaces + shiftwidth = 4, -- the number of spaces inserted for each indentation + tabstop = 4, -- 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 +end + +-- vim.cmd "set whichwrap+=<,>,[,],h,l" +vim.cmd [[set iskeyword+=-]] +vim.cmd [[set formatoptions-=cro]] -- TODO: this doesn't seem to work + +-- Open a file from its last left off position +vim.cmd [[ au BufReadPost * if expand('%:p') !~# '\m/\.git/' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif ]] diff --git a/lua/user/plugins.lua b/lua/user/plugins.lua new file mode 100644 index 0000000..d1e7c69 --- /dev/null +++ b/lua/user/plugins.lua @@ -0,0 +1,59 @@ +local fn = vim.fn +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]] +end + +-- Autocommand that reloads neovim whenever you save the plugins.lua file +vim.cmd([[ + augroup packer_user_config + autocmd! + autocmd BufWritePost plugins.lua source | PackerSync + augroup end +]]) + +local status, packer = pcall(require, "packer") +if not status then + return +end + +packer.init { + display = { + open_fn = function() + return require("packer.util").float { border = "rounded" } + end, + }, +} + +return packer.startup(function(use) +-- 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" + +-- snippets + use "L3MON4D3/LuaSnip" + +-- LSP + use "neovim/nvim-lspconfig" + use "williamboman/nvim-lsp-installer" + +-- Other + 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 +end) -- cgit v1.2.3