From cc048cbc98fc1b1a94377f99c8ff15bd93d8781d Mon Sep 17 00:00:00 2001 From: Ruthenic Date: Fri, 24 Dec 2021 16:29:53 -0500 Subject: [PATCH] Big reorganize of plugin config --- lua/plugins.lua | 175 ------------------------------------------ lua/plugins/init.lua | 3 + lua/plugins/lines.lua | 88 +++++++++++++++++++++ lua/plugins/lsp.lua | 71 +++++++++++++++++ lua/plugins/misc.lua | 18 +++++ 5 files changed, 180 insertions(+), 175 deletions(-) delete mode 100644 lua/plugins.lua create mode 100644 lua/plugins/init.lua create mode 100644 lua/plugins/lines.lua create mode 100644 lua/plugins/lsp.lua create mode 100644 lua/plugins/misc.lua diff --git a/lua/plugins.lua b/lua/plugins.lua deleted file mode 100644 index 42a1c3c..0000000 --- a/lua/plugins.lua +++ /dev/null @@ -1,175 +0,0 @@ -local get_hex = require('cokeline/utils').get_hex ---local coq = require "coq" -local cmp = require('cmp') --- local highlight = require "todo-comments.highlight" - -require("filetype").setup { - overrides = { - extensions = {v = "vlang"} - } -} - -cmp.setup({ - snippet = { - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) - end - }, - mapping = { - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), - [''] = cmp.mapping.confirm({ select = true }), - [''] = function(fallback) - if cmp.visible() then - cmp.select_next_item() - else - fallback() - end - end - }, - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'nvim_lua' }, - { name = 'vsnip' }, - { name = 'buffer' } - }) -}) -local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) - -require'lspconfig'.clangd.setup{ - capabilities = capabilities -} -require'lspconfig'.denols.setup{ - cmd = {'deno', 'lsp'}, - capabilities = capabilities -} -require'lspconfig'.vls.setup{ - cmd = {'/usr/local/bin/vls'}, - capabilities = capabilities -} - -local runtime_path = vim.split(package.path, ';') -table.insert(runtime_path, "lua/?.lua") -table.insert(runtime_path, "lua/?/init.lua") -local sumneko_root_path = '/home/ruthenic/lua-language-server/bin/Linux/' -require'lspconfig'.sumneko_lua.setup { - cmd = {sumneko_root_path .. "lua-language-server", "-E", sumneko_root_path .. "main.lua"}, - settings = { - Lua = { - runtime = { - version = 'LuaJIT', - path = runtime_path, - }, - diagnostics = { - globals = {'vim', 'use'}, - }, - workspace = { - library = vim.api.nvim_get_runtime_file("", true), - }, - telemetry = { - enable = false, - }, - }, - }, - capabilities = capabilities -} - -require('nvim-treesitter.configs').setup { - highlight = { - enable = true, - disable = {"lua"} - } -} - - - -local function filenameIfFileOpened() - local filename = vim.fn.expand('%:t') - if filename == '' then - return '' - elseif filename == 'COMMIT_EDITMSG' then - return '[Git commit]' - elseif vim.bo.modified then - return filename .. '*' - else - return filename - end -end - -require('lualine').setup { - options = { - icons_enabled = true, - theme = 'sonokai', - component_separators = {left = '', right = ''}, - section_separators = {left = '', right = ''}, - disabled_filetypes = {} - }, - sections = { - lualine_a = {'mode'}, - lualine_b = {'branch'}, - lualine_c = {filenameIfFileOpened}, - lualine_x = {'fileformat'}, - lualine_y = {'diff'}, - lualine_z = {'filetype'} - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = {filenameIfFileOpened}, - lualine_x = {'location'}, - lualine_y = {}, - lualine_z = {} - }, - tabline = {}, - extensions = {} -} - --- Credit to the original author of cokeline for creating most of this config -require('cokeline').setup({ - default_hl = { - focused = { - fg = get_hex('Normal', 'fg'), - bg = get_hex('Background', 'bg'), - }, - unfocused = { - fg = get_hex('Comment', 'fg'), - bg = get_hex('Background', 'bg'), - }, - }, - - components = { - { - text = function(buffer) - if buffer.is_focused then - return '│ ' .. buffer.devicon.icon - else - return '| ' .. buffer.devicon.icon - end - end, - hl = { - fg = function(buffer) return buffer.devicon.color end, - }, - }, - { - text = function(buffer) return buffer.unique_prefix end, - hl = { - style = 'italic', - }, - }, - { - text = function(buffer) return buffer.filename .. ' ' end, - }, - { - text = 'X', - delete_buffer_on_left_click = true, - }, - { - text = ' ', - }, - }, -}) - -require('telescope').load_extension('fzf') - ---require('mini.completion').setup() -require('mini.cursorword').setup() -require('mini.pairs').setup() diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua new file mode 100644 index 0000000..01b9111 --- /dev/null +++ b/lua/plugins/init.lua @@ -0,0 +1,3 @@ +require("plugins/lsp") +require("plugins/lines") +require("plugins/misc") diff --git a/lua/plugins/lines.lua b/lua/plugins/lines.lua new file mode 100644 index 0000000..ba56b0a --- /dev/null +++ b/lua/plugins/lines.lua @@ -0,0 +1,88 @@ +local get_hex = require('cokeline/utils').get_hex + +--INFO: Specialized function to return the filename if it's an actual file +local function filenameIfFileOpened() + local filename = vim.fn.expand('%:t') + if filename == '' then + return '' + elseif filename == 'COMMIT_EDITMSG' then + return '[Git commit]' + elseif vim.bo.modified then + return filename .. '*' + else + return filename + end +end + +require('lualine').setup({ + options = { + icons_enabled = true, + theme = 'sonokai', + component_separators = {left = '', right = ''}, + section_separators = {left = '', right = ''}, + disabled_filetypes = {} + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch'}, + lualine_c = {filenameIfFileOpened}, + lualine_x = {'fileformat'}, + lualine_y = {'diff'}, + lualine_z = {'filetype'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {filenameIfFileOpened}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + extensions = {} +}) + +-- Credit to the original author of cokeline for creating most of this config +require('cokeline').setup({ + default_hl = { + focused = { + fg = get_hex('Normal', 'fg'), + bg = get_hex('Background', 'bg'), + }, + unfocused = { + fg = get_hex('Comment', 'fg'), + bg = get_hex('Background', 'bg'), + }, + }, + + components = { + { + text = function(buffer) + if buffer.is_focused then + return '│ ' .. buffer.devicon.icon + else + return '| ' .. buffer.devicon.icon + end + end, + hl = { + fg = function(buffer) return buffer.devicon.color end, + }, + }, + { + text = function(buffer) return buffer.unique_prefix end, + hl = { + style = 'italic', + }, + }, + { + text = function(buffer) return buffer.filename .. ' ' end, + }, + { + text = 'X', + delete_buffer_on_left_click = true, + }, + { + text = ' ', + }, + }, +}) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..93f3453 --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,71 @@ +--INFO: Setup various LSP servers, and completion engines +--TODO: use nvim-lsp-installer? +local cmp = require("cmp") + +cmp.setup({ + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end + }, + mapping = { + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + [''] = cmp.mapping.confirm({ select = true }), + [''] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end + }, + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'nvim_lua' }, + { name = 'vsnip' }, + { name = 'buffer' } + }) +}) +local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) + +require'lspconfig'.clangd.setup({ + capabilities = capabilities +}) + +require'lspconfig'.denols.setup({ + cmd = {'deno', 'lsp'}, + capabilities = capabilities +}) + +require'lspconfig'.vls.setup({ + cmd = {'/usr/local/bin/vls'}, + capabilities = capabilities +}) + +--TODO: clean this up +local runtime_path = vim.split(package.path, ';') +table.insert(runtime_path, "lua/?.lua") +table.insert(runtime_path, "lua/?/init.lua") +local sumneko_root_path = '/home/ruthenic/lua-language-server/bin/Linux/' +require'lspconfig'.sumneko_lua.setup({ + cmd = {sumneko_root_path .. "lua-language-server", "-E", sumneko_root_path .. "main.lua"}, + settings = { + Lua = { + runtime = { + version = 'LuaJIT', + path = runtime_path, + }, + diagnostics = { + globals = {'vim', 'use'}, + }, + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + }, + telemetry = { + enable = false, + }, + }, + }, + capabilities = capabilities +}) + diff --git a/lua/plugins/misc.lua b/lua/plugins/misc.lua new file mode 100644 index 0000000..faf8a5e --- /dev/null +++ b/lua/plugins/misc.lua @@ -0,0 +1,18 @@ +require("filetype").setup { + overrides = { + extensions = {v = "vlang"} + } +} + + +require('nvim-treesitter.configs').setup { + highlight = { + enable = true, + disable = {"lua"} + } +} + +require('telescope').load_extension('fzf') + +require('mini.cursorword').setup() +require('mini.pairs').setup()