From 04451fa63d5ac722c830924867077c0e90c92741 Mon Sep 17 00:00:00 2001 From: Quentin Boyer Date: Fri, 5 Nov 2021 23:28:40 +0100 Subject: [PATCH] formatting --- home.nix | 20 ++-- nvim/init.lua | 4 +- nvim/lua/completion.lua | 46 ++++----- nvim/lua/lsp.lua | 122 +++++++++++------------ nvim/lua/statusline.lua | 210 ++++++++++++++++++++------------------- nvim/lua/tree_sitter.lua | 36 +++++-- 6 files changed, 231 insertions(+), 207 deletions(-) diff --git a/home.nix b/home.nix index 9dc06b1..e7893bd 100644 --- a/home.nix +++ b/home.nix @@ -148,16 +148,16 @@ in ]; initExtra = '' - export PATH="$PATH:${localinfo.homeDir}/bin" - source ~/.p10k.zsh - source ~/.powerlevel10k/powerlevel10k.zsh-theme - eval "$(${pkgs.direnv}/bin/direnv hook zsh)" - if [ -f "$HOME/.zvars" ]; then - source "$HOME/.zvars" - fi - ${pkgs.fortune}/bin/fortune \ - | ${pkgs.cowsay}/bin/cowsay \ - | dotacat + export PATH="$PATH:${localinfo.homeDir}/bin" + source ~/.p10k.zsh + source ~/.powerlevel10k/powerlevel10k.zsh-theme + eval "$(${pkgs.direnv}/bin/direnv hook zsh)" + if [ -f "$HOME/.zvars" ]; then + source "$HOME/.zvars" + fi + ${pkgs.fortune}/bin/fortune \ + | ${pkgs.cowsay}/bin/cowsay \ + | dotacat ''; shellAliases = { cat = "${pkgs.bat}/bin/bat -p"; diff --git a/nvim/init.lua b/nvim/init.lua index c746bf6..5bbd743 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -29,7 +29,7 @@ vim.g.grammalecte_cli_py = "/usr/bin/grammalecte-cli" latex_ignore = [[ typo_guillemets_typographiques_simples_doubles_ouvrants typo_guillemets_typographiques_simples_doubles_fermants - esp_milieu_ligne + esp_milieu_ligne ]] vim.g.grammalecte_disable_rules = [[ apostrophe_typographique apostrophe_typographique_après_t @@ -43,7 +43,7 @@ vim.g.grammalecte_disable_rules = [[ apostrophe_typographique nbsp_avant_chevrons_fermants1 unit_nbsp_avant_unités1 unit_nbsp_avant_unités2 - unit_nbsp_avant_unités3 + unit_nbsp_avant_unités3 typo_espace_manquant_après2 ]] .. latex_ignore vim.g.languagetool_cmd = "/usr/bin/languagetool" diff --git a/nvim/lua/completion.lua b/nvim/lua/completion.lua index da9b3e5..e10a948 100644 --- a/nvim/lua/completion.lua +++ b/nvim/lua/completion.lua @@ -1,27 +1,27 @@ -require'lsp_signature'.on_attach() +require("lsp_signature").on_attach() -local cmp = require'cmp' +local cmp = require("cmp") cmp.setup({ - snippet = { - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` user. - end, - }, - mapping = { - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.close(), - [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 's' }), - [''] = cmp.mapping.confirm({ select = true }), - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'vsnip' }, - { name = 'buffer' }, - { name = 'path' }, - { name = 'calc' }, - { name = 'latex_symbols' } - } + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` user. + end, + }, + mapping = { + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.close(), + [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "s" }), + [""] = cmp.mapping.confirm({ select = true }), + }, + sources = { + { name = "nvim_lsp" }, + { name = "vsnip" }, + { name = "buffer" }, + { name = "path" }, + { name = "calc" }, + { name = "latex_symbols" }, + }, }) diff --git a/nvim/lua/lsp.lua b/nvim/lua/lsp.lua index 07e77f1..7ea00a3 100644 --- a/nvim/lua/lsp.lua +++ b/nvim/lua/lsp.lua @@ -11,86 +11,86 @@ local sources = { null_ls.config({ sources = sources }) -local lsp_status = require('lsp-status') +local lsp_status = require("lsp-status") lsp_status.register_progress() local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true -capabilities = vim.tbl_extend('keep', capabilities, lsp_status.capabilities) +capabilities = vim.tbl_extend("keep", capabilities, lsp_status.capabilities) -require('lspkind').init({}) -local lspconfig = require'lspconfig' -local configs = require'lspconfig/configs' -local util = require 'lspconfig/util' +require("lspkind").init({}) +local lspconfig = require("lspconfig") +local configs = require("lspconfig/configs") +local util = require("lspconfig/util") if not lspconfig.rsh_lsp then configs.rsh_lsp = { - default_config = { - cmd = {'rsh-lsp'}, - filetypes = {'rsh'}, + default_config = { + cmd = { "rsh-lsp" }, + filetypes = { "rsh" }, root_dir = util.path.dirname, - settings = {}, - }; - } + settings = {}, + }, + } end -lspconfig["null-ls"].setup{ - on_attach=lsp_status.on_attach, -} -lspconfig.rust_analyzer.setup{ - on_attach=lsp_status.on_attach, +lspconfig["null-ls"].setup({ + on_attach = lsp_status.on_attach, +}) +lspconfig.rust_analyzer.setup({ + on_attach = lsp_status.on_attach, settings = { ["rust-analyzer"] = { - procMacro = { - enable = true + procMacro = { + enable = true, }, cargo = { allFeatures = true, - loadOutDirsFromCheck = true + loadOutDirsFromCheck = true, }, updates = { - channel = "nightly" + channel = "nightly", }, - } + }, }, - capabilities = capabilities -} -lspconfig.jsonls.setup{ - on_attach=lsp_status.on_attach, + capabilities = capabilities, +}) +lspconfig.jsonls.setup({ + on_attach = lsp_status.on_attach, cmd = { "json-languageserver", "--stdio" }, - capabilities = capabilities -} -lspconfig.bashls.setup{ - on_attach=lsp_status.on_attach, - capabilities = capabilities -} -lspconfig.rsh_lsp.setup{ - on_attach=lsp_status.on_attach, - capabilities = capabilities -} -lspconfig.clangd.setup{ - on_attach = lsp_status.on_attach, - handlers = lsp_status.extensions.clangd.setup(), - init_options = { clangdFileStatus = true}, - capabilities = capabilities -} -lspconfig.texlab.setup{ - on_attach = lsp_status.on_attach, - capabilities = capabilities -} - -lspconfig.rnix.setup{ - on_attach = lsp_status.on_attach, - capabilities = capabilities -} - -lspconfig.dartls.setup{ + capabilities = capabilities, +}) +lspconfig.bashls.setup({ on_attach = lsp_status.on_attach, capabilities = capabilities, - cmd = {"dart", vim.fn.expand("$DART_SDK") .. "/snapshots/analysis_server.dart.snapshot", "--lsp"} -} +}) +lspconfig.rsh_lsp.setup({ + on_attach = lsp_status.on_attach, + capabilities = capabilities, +}) +lspconfig.clangd.setup({ + on_attach = lsp_status.on_attach, + handlers = lsp_status.extensions.clangd.setup(), + init_options = { clangdFileStatus = true }, + capabilities = capabilities, +}) +lspconfig.texlab.setup({ + on_attach = lsp_status.on_attach, + capabilities = capabilities, +}) -lspconfig.vuels.setup{ +lspconfig.rnix.setup({ + on_attach = lsp_status.on_attach, + capabilities = capabilities, +}) + +lspconfig.dartls.setup({ + on_attach = lsp_status.on_attach, + capabilities = capabilities, + cmd = { "dart", vim.fn.expand("$DART_SDK") .. "/snapshots/analysis_server.dart.snapshot", "--lsp" }, +}) + +lspconfig.vuels.setup({ on_attach = lsp_status.on_attach, capabilities = capabilities, config = { @@ -98,8 +98,8 @@ lspconfig.vuels.setup{ defaultFormatter = { js = "prettier", ts = "prettier", - html = "prettier" - } - } - } -} + html = "prettier", + }, + }, + }, +}) diff --git a/nvim/lua/statusline.lua b/nvim/lua/statusline.lua index 416862c..ffaa0cd 100644 --- a/nvim/lua/statusline.lua +++ b/nvim/lua/statusline.lua @@ -54,27 +54,27 @@ require'feline'.setup { vi_mode_colors = vi_mode_colors } ]] -local gl = require('galaxyline') +local gl = require("galaxyline") local gls = gl.section -gl.short_line_list = {'LuaTree','vista','dbui'} +gl.short_line_list = { "LuaTree", "vista", "dbui" } local colors = { - bg = '#282c34', - yellow = '#fabd2f', - cyan = '#008080', - darkblue = '#081633', - green = '#afd700', - orange = '#FF8800', - purple = '#5d4d7a', - magenta = '#d16d9e', - grey = '#c0c0c0', - blue = '#0087d7', - red = '#ec5f67', - violet = '#6860e7' + bg = "#282c34", + yellow = "#fabd2f", + cyan = "#008080", + darkblue = "#081633", + green = "#afd700", + orange = "#FF8800", + purple = "#5d4d7a", + magenta = "#d16d9e", + grey = "#c0c0c0", + blue = "#0087d7", + red = "#ec5f67", + violet = "#6860e7", } local buffer_not_empty = function() - if vim.fn.empty(vim.fn.expand('%:t')) ~= 1 then + if vim.fn.empty(vim.fn.expand("%:t")) ~= 1 then return true end return false @@ -85,194 +85,204 @@ local fileinfo = require("galaxyline.providers.fileinfo") -- Start of line gls.left[1] = { FirstElement = { - provider = function() return '▋' end, - highlight = {colors.blue,colors.yellow} + provider = function() + return "▋" + end, + highlight = { colors.blue, colors.yellow }, }, } -- Vim mode gls.left[2] = { ViMode = { provider = function() - local alias = {n = 'NORMAL ',i = 'INSERT ',c= 'COMMAND ',V= 'VISUAL ', [''] = 'VISUAL '} + local alias = { n = "NORMAL ", i = "INSERT ", c = "COMMAND ", V = "VISUAL ", [""] = "VISUAL " } return alias[vim.fn.mode()] end, - separator = '', - separator_highlight = {colors.yellow,function() - if not buffer_not_empty() then - return colors.purple - end - return colors.darkblue - end}, - highlight = {colors.violet,colors.yellow,'bold'}, + separator = "", + separator_highlight = { + colors.yellow, + function() + if not buffer_not_empty() then + return colors.purple + end + return colors.darkblue + end, + }, + highlight = { colors.violet, colors.yellow, "bold" }, }, } -- File Icon -gls.left[3] ={ +gls.left[3] = { FileIcon = { - provider = 'FileIcon', + provider = "FileIcon", condition = buffer_not_empty, - highlight = {fileinfo.get_file_icon_color,colors.darkblue}, + highlight = { fileinfo.get_file_icon_color, colors.darkblue }, }, } -- File Name gls.left[4] = { FileName = { - provider = {'FileName'}, + provider = { "FileName" }, condition = buffer_not_empty, - separator = '', - separator_highlight = {colors.purple,colors.darkblue}, - highlight = {colors.magenta,colors.darkblue} - } + separator = "", + separator_highlight = { colors.purple, colors.darkblue }, + highlight = { colors.magenta, colors.darkblue }, + }, } -- GIT gls.left[5] = { GitIcon = { - provider = function() return '  ' end, + provider = function() + return "  " + end, condition = buffer_not_empty, - highlight = {colors.orange,colors.purple}, - } + highlight = { colors.orange, colors.purple }, + }, } gls.left[6] = { GitBranch = { - provider = 'GitBranch', + provider = "GitBranch", condition = buffer_not_empty, - highlight = {colors.grey,colors.purple}, - } + highlight = { colors.grey, colors.purple }, + }, } local vcs = require("galaxyline.providers.vcs") -local is_file_diff = function () +local is_file_diff = function() if vcs.diff_add() ~= nil or vcs.diff_modified() ~= nil or vcs.diff_remove() ~= nil then - return '' + return "" end end gls.left[7] = { GitModified = { provider = is_file_diff, - highlight = {colors.green,colors.purple}, - } + highlight = { colors.green, colors.purple }, + }, } gls.left[8] = { LeftEnd = { - provider = function() return '' end, - separator = '', - separator_highlight = {colors.purple,colors.bg}, - highlight = {colors.purple,colors.purple} - } + provider = function() + return "" + end, + separator = "", + separator_highlight = { colors.purple, colors.bg }, + highlight = { colors.purple, colors.purple }, + }, } -local lsp_diag_error = function() - local diagnostics = require('lsp-status/diagnostics') +local lsp_diag_error = function() + local diagnostics = require("lsp-status/diagnostics") local buf_diagnostics = diagnostics() if buf_diagnostics.errors and buf_diagnostics.errors > 0 then - return buf_diagnostics.errors .. ' ' + return buf_diagnostics.errors .. " " end end -local lsp_diag_warn = function() - local diagnostics = require('lsp-status/diagnostics') +local lsp_diag_warn = function() + local diagnostics = require("lsp-status/diagnostics") local buf_diagnostics = diagnostics() if buf_diagnostics.warnings and buf_diagnostics.warnings > 0 then - return buf_diagnostics.warnings .. ' ' + return buf_diagnostics.warnings .. " " end end -local lsp_diag_info = function() - local diagnostics = require('lsp-status/diagnostics') +local lsp_diag_info = function() + local diagnostics = require("lsp-status/diagnostics") local buf_diagnostics = diagnostics() if buf_diagnostics.info and buf_diagnostics.info > 0 then - return buf_diagnostics.info .. ' ' + return buf_diagnostics.info .. " " end end -local has_lsp = function () +local has_lsp = function() return #vim.lsp.buf_get_clients() > 0 end -local has_curent_func = function () +local has_curent_func = function() if not has_lsp then return false end local current_function = vim.b.lsp_current_function - return current_function and current_function ~= '' + return current_function and current_function ~= "" end -local lsp_current_func = function () +local lsp_current_func = function() local current_function = vim.b.lsp_current_function - if current_function and current_function ~= '' then - return '(' .. current_function .. ') ' + if current_function and current_function ~= "" then + return "(" .. current_function .. ") " end end - gls.right[1] = { LspText = { - provider = function() return '' end, - separator = '', - separator_highlight = {colors.darkblue,colors.bg}, - highlight = {colors.grey,colors.darkblue}, - } + provider = function() + return "" + end, + separator = "", + separator_highlight = { colors.darkblue, colors.bg }, + highlight = { colors.grey, colors.darkblue }, + }, } gls.right[2] = { LspError = { provider = lsp_diag_error, condition = has_lsp, - icon = ' ', - highlight = {colors.grey,colors.darkblue}, - } + icon = " ", + highlight = { colors.grey, colors.darkblue }, + }, } gls.right[3] = { LspWarning = { provider = lsp_diag_warn, condition = has_lsp, - icon = ' ', - highlight = {colors.grey,colors.darkblue}, - } + icon = " ", + highlight = { colors.grey, colors.darkblue }, + }, } gls.right[4] = { LspInfo = { provider = lsp_diag_info, condition = has_lsp, - icon = ' ', - highlight = {colors.grey,colors.darkblue}, - } + icon = " ", + highlight = { colors.grey, colors.darkblue }, + }, } gls.right[5] = { LspCurrentFunc = { provider = lsp_current_func, condition = has_current_func, - icon = '𝒇', - highlight = {colors.grey,colors.darkblue}, - } + icon = "𝒇", + highlight = { colors.grey, colors.darkblue }, + }, } -gls.right[6]= { +gls.right[6] = { FileFormat = { - provider = 'FileFormat', - separator = '', - separator_highlight = {colors.darkblue,colors.purple}, - highlight = {colors.grey,colors.purple}, - } + provider = "FileFormat", + separator = "", + separator_highlight = { colors.darkblue, colors.purple }, + highlight = { colors.grey, colors.purple }, + }, } gls.right[7] = { LineInfo = { - provider = 'LineColumn', - separator = ' | ', - separator_highlight = {colors.darkblue,colors.purple}, - highlight = {colors.grey,colors.purple}, + provider = "LineColumn", + separator = " | ", + separator_highlight = { colors.darkblue, colors.purple }, + highlight = { colors.grey, colors.purple }, }, } gls.right[8] = { PerCent = { - provider = 'LinePercent', - separator = '', - separator_highlight = {colors.darkblue,colors.purple}, - highlight = {colors.grey,colors.darkblue}, - } + provider = "LinePercent", + separator = "", + separator_highlight = { colors.darkblue, colors.purple }, + highlight = { colors.grey, colors.darkblue }, + }, } gls.right[9] = { ScrollBar = { - provider = 'ScrollBar', - highlight = {colors.yellow,colors.purple}, - } + provider = "ScrollBar", + highlight = { colors.yellow, colors.purple }, + }, } diff --git a/nvim/lua/tree_sitter.lua b/nvim/lua/tree_sitter.lua index 615ab97..212c662 100644 --- a/nvim/lua/tree_sitter.lua +++ b/nvim/lua/tree_sitter.lua @@ -1,19 +1,33 @@ -local parser_config = require "nvim-treesitter.parsers".get_parser_configs() +local parser_config = require("nvim-treesitter.parsers").get_parser_configs() parser_config.rsh = { - install_info = { - url = "https://github.com/traxys/tree-sitter-rsh/", -- local path or git repo - files = {"src/parser.c"} - }, + install_info = { + url = "https://github.com/traxys/tree-sitter-rsh/", -- local path or git repo + files = { "src/parser.c" }, + }, } -require'nvim-treesitter.configs'.setup { - ensure_installed = {"rust", "c", "cpp", "json", "lua", "python", "toml", "latex", "nix", "vue", "javascript", "dart", "rsh"}, +require("nvim-treesitter.configs").setup({ + ensure_installed = { + "rust", + "c", + "cpp", + "json", + "lua", + "python", + "toml", + "latex", + "nix", + "vue", + "javascript", + "dart", + "rsh", + }, ident = { - enable = true + enable = true, }, highlight = { - enable = true, -- false will disable the whole extension - disable = {"elixir", "teal"}, -- list of language that will be disabled + enable = true, -- false will disable the whole extension + disable = { "elixir", "teal" }, -- list of language that will be disabled }, refactor = { highlight_definitions = { enable = true }, @@ -25,4 +39,4 @@ require'nvim-treesitter.configs'.setup { }, }, }, -} +})