From 7e1c5f4418a629d6f3bae954dd172ca81e476b3e Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Fri, 26 Apr 2024 12:48:36 -0400 Subject: update laptop config --- config/nvim/init.lua | 14 ----- config/nvim/init.vim | 71 --------------------- config/nvim/lua/lsp.lua | 145 +++++++++++++++++++++++++++++++++++++++++++ config/nvim/lua/settings.lua | 34 ++++++++++ config/nvim/plugins.lua | 57 ----------------- 5 files changed, 179 insertions(+), 142 deletions(-) delete mode 100644 config/nvim/init.lua delete mode 100644 config/nvim/init.vim create mode 100644 config/nvim/lua/lsp.lua create mode 100644 config/nvim/lua/settings.lua delete mode 100644 config/nvim/plugins.lua (limited to 'config/nvim') diff --git a/config/nvim/init.lua b/config/nvim/init.lua deleted file mode 100644 index 4a80830..0000000 --- a/config/nvim/init.lua +++ /dev/null @@ -1,14 +0,0 @@ -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", - lazypath - }) -end -vim.opt.rtp:prepend(lazypath) - -require("lazy").setup("plugins") diff --git a/config/nvim/init.vim b/config/nvim/init.vim deleted file mode 100644 index 993ea88..0000000 --- a/config/nvim/init.vim +++ /dev/null @@ -1,71 +0,0 @@ -set termguicolors - -filetype plugin indent on -set tabstop=4 softtabstop=4 shiftwidth=4 -set expandtab smarttab -set autoindent -set incsearch ignorecase smartcase hlsearch -set encoding=utf-8 -set textwidth=0 -set number - -set hidden -set title -set noshowmode -set noruler -set noshowcmd - -set nobackup -set nowritebackup - -set updatetime=300 -set signcolumn=yes - -let mapleader = "\" - -" Tab-trigger completion -inoremap - \ coc#pum#visible() ? coc#pum#next(1) : - \ CheckBackspace() ? "\" : - \ coc#refresh() -inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" - -inoremap coc#pum#visible() ? coc#pum#confirm() : - \ "\u\\=coc#on_enter()\" - -function! CheckBackspace() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction - -inoremap coc#refresh() - -nmap [g (coc-diagnostic-prev) -nmap ]g (coc-diagnostic-next) - -nmap gd (coc-definition) -nmap gy (coc-type-definition) -nmap gi (coc-implementation) -nmap gr (coc-references) - -nnoremap K :call ShowDocumentation() - -function! ShowDocumentation() - if CocAction('hasProvider', 'hover') - call CocActionAsync('doHover') - else - call feedkeys('K', 'in') - endif -endfunction - -autocmd CursorHold * silent call CocActionAsync('highlight') - -" Telescope -nnoremap ff Telescope find_files -nnoremap fg Telescope live_grep -nnoremap fb Telescope buffers -nnoremap fh help_tags - -lua require('init') - -color catppuccin diff --git a/config/nvim/lua/lsp.lua b/config/nvim/lua/lsp.lua new file mode 100644 index 0000000..1056431 --- /dev/null +++ b/config/nvim/lua/lsp.lua @@ -0,0 +1,145 @@ +local cmp = require("cmp") +local nvim_lsp = require("lspconfig") +local cmp_window = require("cmp.utils.window") + +vim.o.completeopt = "menuone,noselect" +vim.o.shortmess = vim.o.shortmess .. "c" + +local function on_attach(client, bufn) + local function map(...) + vim.api.nvim_buf_set_keymap(bufn, ...) + end + + local function buf_set_option(...) + vim.api.nvim_buf_set_option(bufn, ...) + end + + local opts = { noremap = true, silent = true } + map("n", "gD", "lua vim.lsp.buf.declaration()", opts) + map("n", "gd", "lua vim.lsp.buf.definition()", opts) + map("n", "K", "lua vim.lsp.buf.hover()", opts) + map("n", "gi", "lua vim.lsp.buf.implementation()", opts) + map("n", "", "lua vim.lsp.buf.signature_help()", opts) + map("n", "D", "lua vim.lsp.buf.type_definition()", opts) + map("n", "gr", "lua vim.lsp.buf.references()", opts) + map("n", "e", "lua vim.lsp.diagnostic.show_line_diagnostics()", opts) + map("n", "[d", "lua vim.lsp.diagnostic.goto_prev()", opts) + map("n", "]d", "lua vim.lsp.diagnostic.goto_next()", opts) + map("n", "q", "lua vim.lsp.diagnostic.set_loclist()", opts) + map("n", "ga", "lua vim.lsp.buf.code_action()", opts) +end + +local function has_words_before() + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil +end + +local function feedkey(key, mode) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) +end + +local function border(hl_name) + return { + { "╭", hl_name }, + { "─", hl_name }, + { "╮", hl_name }, + { "│", hl_name }, + { "╯", hl_name }, + { "─", hl_name }, + { "╰", hl_name }, + { "│", hl_name }, + } +end + +cmp_window.info_ = cmp_window.info +cmp_window.info = function(self) + local info = self:info_() + info.scrollable = false + return info +end + +cmp.setup({ + window = { + completion = { + border = border "CmpBorder", + winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None", + }, + documentation = { + border = border "CmpDocBorder" + }, + }, + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({select = true}), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif vim.fn["vsnip#available"](1) == 1 then + feedkey("(vsnip-expand-or-jump)", "") + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, {"i", "s"}), + + ["(vsnip-jump-prev)", "") + end + end, {"i", "s"}), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "vsnip" }, + { name = "treesitter" }, + { name = "path", option = { trailing_slash = true }}, + { name = "buffer" } + }), +}) + +cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), +}) + +vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( + vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = true, + signs = true, + update_in_insert = true + } +) + +local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) + +local servers = { "ccls", "bashls", "rnix", "texlab", "lua_ls" } + +for _, lang in pairs(servers) do + nvim_lsp[lang].setup({ + root_dir = vim.loop.cwd, + on_attach = on_attach, + capabilities = capabilities + }) +end + +require("nvim-treesitter.configs").setup({ + highlight = { enable = true, }, +}) + +require("gitsigns").setup({}) + diff --git a/config/nvim/lua/settings.lua b/config/nvim/lua/settings.lua new file mode 100644 index 0000000..6f440bb --- /dev/null +++ b/config/nvim/lua/settings.lua @@ -0,0 +1,34 @@ +vim.g.mapleader = " " + +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +--Decorative +vim.opt.termguicolors = true +vim.opt.cursorline = true +vim.opt.number = true +vim.opt.signcolumn = "yes" +vim.opt.cmdheight = 1 +vim.cmd.colorscheme "catppuccin" + +--Undo +vim.opt.undofile = true + +--Indents +vim.opt.smartindent = true +vim.opt.autoindent = true +vim.opt.tabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.softtabstop = 4 +vim.opt.expandtab = true + +--Clipboard +vim.opt.clipboard = "unnamedplus" + +--Misc +vim.opt.hidden = true +vim.opt.smartcase = true +vim.opt.splitbelow = true +vim.opt.splitright = true +vim.opt.colorcolumn = "80" +vim.opt.updatetime = 250 diff --git a/config/nvim/plugins.lua b/config/nvim/plugins.lua deleted file mode 100644 index 83c74ad..0000000 --- a/config/nvim/plugins.lua +++ /dev/null @@ -1,57 +0,0 @@ -return -{ - { "neovim/nvim-lspconfig" }, - { "MordechaiHadad/nvim-lspmanager", - dependencies = { "neovim/nvim-lspconfig" }, - config = function() - require('lspmanager').setup({ - ensure_installed = { - "clangd" - } - }) - end - }, - { "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - config = function() - require('nvim-treesitter.configs').setup{ - ensure_installed = { "c", "cpp" }, - auto_install = true, - highlight = { - enable = true - } - } - end - }, - { "neoclide/coc.nvim", branch="release" }, - { "nvim-lua/plenary.nvim" }, - { "nvim-telescope/telescope.nvim", tag = '0.1.3', - dependencies = { 'nvim-lua/plenary.nvim' } - }, - { "nvim-tree/nvim-web-devicons" }, - { "lewis6991/gitsigns.nvim", - config = function() - require('gitsigns').setup() - end - }, - { "tpope/vim-surround" }, - { "catppuccin/nvim", name="catppuccin", priority=1000 }, - { "feline-nvim/feline.nvim", - config = function() - local ctp_feline = require('catppuccin.groups.integrations.feline') - require('feline').setup({ - - }) - end - }, - { "romgrk/barbar.nvim", - dependencies = { - 'lewis6991/gitsigns.nvim', - 'nvim-tree/nvim-web-devicons' - }, - init = function() vim.g.barbar_auto_setup = false end, - config = function() - require('barbar').setup() - end - } -} -- cgit v1.2.1