diff --git a/home/.config/doom/config.el b/home/.config/doom/config.el index d24bb5c..7adef75 100644 --- a/home/.config/doom/config.el +++ b/home/.config/doom/config.el @@ -173,6 +173,7 @@ "--header-insertion=iwyu" "--header-insertion-decorators")) (after! lsp-clangd (set-lsp-priority! 'clangd 2)) ;; Prefer clangd instead of default ccls +;; Self-built lua-language-server in .local/etc/lsp/lua-language-server (after! lsp-lua (setq lsp-clients-lua-language-server-bin (expand-file-name "lsp/lua-language-server/bin/Linux/lua-language-server" doom-etc-dir) lsp-clients-lua-language-server-main-location (expand-file-name "lsp/lua-language-server/main.lua" doom-etc-dir) @@ -184,6 +185,13 @@ (after! which-key (setq which-key-idle-delay 0.5)) +;; Self-built parinfer-rust in .local/etc/parinfer-rust (cargo build --release --features emacs) +(use-package! parinfer-rust-mode + :init + (setq parinfer-rust-library + (concat doom-etc-dir "parinfer-rust/target/release/libparinfer_rust.so") + parinfer-rust-auto-download nil)) + ;; Org (setq org-directory "~/Documents/Org/") (after! org diff --git a/home/.config/doom/init.el b/home/.config/doom/init.el index 8ab763a..14bcb17 100644 --- a/home/.config/doom/init.el +++ b/home/.config/doom/init.el @@ -71,7 +71,7 @@ ;;lispy ; vim for lisp, for people who don't like vim multiple-cursors ; editing in many places at once ;;objed ; text object editing for the innocent - ;;(parinfer +rust) ; turn lisp into python, sort of + (parinfer +rust) ; turn lisp into python, sort of ;;rotate-text ; cycle region at point between text candidates snippets ; my elves. They type so I don't have to ;;word-wrap ; soft wrapping with language-aware indent diff --git a/home/.config/nvim/lua/colors/nord.lua b/home/.config/nvim/lua/colors/nord.lua index 4c4f845..eea026b 100644 --- a/home/.config/nvim/lua/colors/nord.lua +++ b/home/.config/nvim/lua/colors/nord.lua @@ -308,10 +308,10 @@ local function highlight_plugins() hi('EftSubChar', c.grey3, '', 'bold,underline', '') -- dashboard-nvim / alpha-nvim - hi('DashboardHeader' , c.cyan , '', 'bold' , '') - hi('DashboardCenter' , c.blue , '', 'bold' , '') + hi('DashboardHeader' , c.blue , '', 'bold' , '') + hi('DashboardCenter' , c.green , '', 'bold' , '') hi('DashboardShortcut', c.grey_bright, '', 'bold,italic', '') - hi('DashboardFooter' , c.green , '', 'bold' , '') + hi('DashboardFooter' , c.purple , '', 'bold' , '') -- NvimTree hi('NvimTreeRootFolder' , c.teal , '', 'bold', '') diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index 56cbecd..bbca6eb 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -129,7 +129,7 @@ wk.register({ d = {':bdelete', 'Close buffer'}, j = {':BufferLineCyclePrev', 'Previous buffer'}, k = {':BufferLineCycleNext', 'Next buffer'}, - n = {':enew startinsert ', 'New buffer'}, + n = {':enew', 'New buffer'}, u = {':UndotreeToggle', 'Undotree'}, z = {':ZenMode', 'Zen mode'} }, @@ -161,6 +161,7 @@ wk.register({ a = {':Telescope autocommands', 'Autocommands'}, b = {':Telescope buffers', 'Buffers'}, c = {':Telescope commands', 'Commands'}, + d = {':Telescope projects', 'Recent directories'}, e = {':Telescope file_browser', 'File browser'}, f = {':Telescope find_files', 'Find files'}, g = {':Telescope live_grep', 'Live grep'}, diff --git a/home/.config/nvim/lua/modules/editor.lua b/home/.config/nvim/lua/modules/editor.lua index dbdf42b..6b90001 100644 --- a/home/.config/nvim/lua/modules/editor.lua +++ b/home/.config/nvim/lua/modules/editor.lua @@ -149,4 +149,15 @@ function M.comment_conf() require('nvim_comment').setup({comment_empty = false}) end +function M.project_conf() + require('project_nvim').setup { + manual_mode = false, + detection_methods = {'pattern', 'lsp'}, + patterns = {'.git', '_darcs', '.hg', '.bzr', '.svn', 'Makefile', 'package.json', '*.pro', 'Dockerfile', '>Code'}, + show_hidden = true, + silent_chdir = true, + datapath = vim.fn.stdpath('data') + } +end + return M diff --git a/home/.config/nvim/lua/modules/tools.lua b/home/.config/nvim/lua/modules/tools.lua index f7a38fe..716d572 100644 --- a/home/.config/nvim/lua/modules/tools.lua +++ b/home/.config/nvim/lua/modules/tools.lua @@ -28,7 +28,8 @@ function M.telescope_conf() }, extensions = { project = { - base_dirs = {{'~/Code', max_depth = 2}} + base_dirs = {{'~/Code', max_depth = 4}}, + hidden_files = true }, fzf = { fuzzy = true, @@ -38,6 +39,7 @@ function M.telescope_conf() } } } + require('telescope').load_extension('projects') require('telescope').load_extension('project') require('telescope').load_extension('fzf') end @@ -259,6 +261,37 @@ function M.neoscroll_conf() require('neoscroll').setup() end +function M.sniprun_conf() + local c = require('colors.' .. vim.g.global_theme).colors + + require('sniprun').setup { + display = { + 'Classic', --# display results in the command-line area + 'VirtualTextOk', --# display ok results as virtual text (multiline is shortened) + -- 'VirtualTextErr', --# display error results as virtual text + -- 'TempFloatingWindow', --# display results in a floating window + -- 'LongTempFloatingWindow', --# same as above, but only long results. To use with VirtualText__ + -- 'Terminal', --# display results in a vertical split + -- 'NvimNotify', --# display with the nvim-notify plugin + -- 'Api' --# return output to a programming interface + }, + show_no_output = { + 'Classic', + 'TempFloatingWindow' --# implies LongTempFloatingWindow, which has no effect on its own + }, + snipruncolors = { + SniprunVirtualTextOk = {bg = c.cyan, fg = c.black}, + SniprunFloatingWinOk = {fg = c.cyan}, + SniprunVirtualTextErr = {bg = c.orange, fg = c.black}, + SniprunFloatingWinErr = {fg = c.orange} + }, + inline_messages = 0, --# inline_message (0/1) is a one-line way to display messages + --# to workaround sniprun not being able to display anything + borders = 'single' --# display borders around floating windows + --# possible values are 'none', 'single', 'double', or 'shadow' + } +end + function M.session_conf() require('persistence').setup { dir = vim.fn.expand(vim.fn.stdpath('data') .. '/sessions/'), diff --git a/home/.config/nvim/lua/modules/ui.lua b/home/.config/nvim/lua/modules/ui.lua index d8c9667..c289231 100644 --- a/home/.config/nvim/lua/modules/ui.lua +++ b/home/.config/nvim/lua/modules/ui.lua @@ -65,11 +65,12 @@ function M.dashboard_conf() dashboard.section.buttons = { type = 'group', val = { - button('SPC b n', ' New file'), + button('SPC f g', ' Find word'), button('SPC f f', ' Find file'), button('SPC f o', ' Recent files'), - button('SPC f g', ' Find word'), + button('SPC f d', 'ﱮ Recent directories'), button('SPC f m', ' Bookmarks'), + button('SPC f p', ' Projects'), button('SPC e l', ' Load last session') }, opts = {spacing = 1} @@ -93,237 +94,202 @@ autocmd FileType alpha set showtabline=0 | autocmd BufUnload set showta end function M.statusline_conf() - local gl = require('galaxyline') - local gls = gl.section - local condition = require('galaxyline.condition') local colors = require('colors.' .. vim.g.global_theme).colors - gl.short_line_list = {'NvimTree', 'packer', 'Outline'} - - gls.left[1] = { - LeftCorner = { - provider = function() - return '▊ ' - end, - highlight = {colors.blue, colors.grey1} - } + local vi_mode_colors = { + NORMAL = colors.green, + OP = colors.green, + INSERT = colors.blue, + VISUAL = colors.yellow, + LINES = colors.yellow, + BLOCK = colors.yellow, + REPLACE = colors.red, + ['V-REPLACE'] = colors.red, + ENTER = colors.cyan, + MORE = colors.cyan, + SELECT = colors.orange, + COMMAND = colors.purple, + SHELL = colors.green, + TERM = colors.green, + NONE = colors.white2 } - gls.left[2] = { - ViMode = { - provider = function() - local mode_color = { - n = colors.green, -- Normal - no = colors.green, -- N-Pending - i = colors.blue, -- Insert - ic = colors.blue, -- Insert - v = colors.yellow, -- Visual - [''] = colors.yellow, -- V-Block - V = colors.yellow, -- V-Line - c = colors.white2, -- Command - s = colors.purple, -- Select - S = colors.purple, -- S-Line - [''] = colors.purple, -- S-Block - R = colors.red, -- Replace - Rv = colors.red, -- V-Replace - cv = colors.white2, -- Vim-Ex - ce = colors.white2, -- Ex - r = colors.cyan, -- Prompt - rm = colors.cyan, -- More - ['r?'] = colors.cyan, -- Confirm - ['!'] = colors.orange, -- Shell - t = colors.orange -- Terminal + local function file_osinfo() + local os = vim.bo.fileformat:upper() + local icon + if os == 'UNIX' then + icon = ' ' + elseif os == 'MAC' then + icon = ' ' + else + icon = ' ' + end + return icon .. os + end + + local vi_mode_utils = require('feline.providers.vi_mode') + + local comps = { + dummy = { + provider = '▊', + hl = {fg = colors.blue}, + right_sep = ' ' + }, + vi_mode = { + provider = ' ', + hl = function() + return { + name = vi_mode_utils.get_mode_highlight_name(), + fg = vi_mode_utils.get_mode_color() } - vim.api.nvim_command('hi GalaxyViMode guifg=' .. mode_color[vim.fn.mode()]) - return ' ' - end, - highlight = {colors.green, colors.grey1} - } - } - - gls.left[3] = { - FileSize = { - provider = 'FileSize', - condition = condition.buffer_not_empty, - highlight = {colors.fg, colors.grey1} - } - } - - gls.left[4] ={ - FileIcon = { - provider = 'FileIcon', - condition = condition.buffer_not_empty, - highlight = { - require('galaxyline.provider_fileinfo').get_file_icon_color, - colors.grey1 - } - } - } - - gls.left[5] = { - FileName = { - provider = 'FileName', - condition = condition.buffer_not_empty, - highlight = {colors.fg, colors.grey1, 'bold'} - } - } - - gls.left[6] = { - LineInfo = { - provider = 'LineColumn', - highlight = {colors.fg, colors.grey1} - } - } - - gls.left[7] = { - PerCent = { - provider = 'LinePercent', - highlight = {colors.fg, colors.grey1, 'bold'} - } - } - - gls.left[8] = { - DiagnosticError = { - provider = 'DiagnosticError', - icon = '  ', - highlight = {colors.red, colors.grey1} - } - } - - gls.left[9] = { - DiagnosticWarn = { - provider = 'DiagnosticWarn', - icon = '  ', - highlight = {colors.yellow, colors.grey1} - } - } - - gls.left[10] = { - DiagnosticHint = { - provider = 'DiagnosticHint', - icon = '  ', - highlight = {colors.cyan, colors.grey1} - } - } - - gls.left[11] = { - DiagnosticInfo = { - provider = 'DiagnosticInfo', - icon = '  ', - highlight = {colors.blue, colors.grey1} - } - } - - gls.right[1] = { - ShowLspClient = { - provider = 'GetLspClient', - condition = function () - local tbl = {['dashboard'] = true, [''] = true} - if tbl[vim.bo.filetype] then - return false - end - return true end, + right_sep = ' ' + }, + filesize = { + provider = 'file_size', + hl = {fg = colors.fg, style = 'bold'}, + right_sep = ' ' + }, + fileinfo = { + provider = { + name = 'file_info', + opts = { + file_modified_icon = ' ', + file_readonly_icon = '🔒', + type = 'base-only' -- relative, unique + } + }, + hl = {fg = colors.blue, style = 'bold'}, + right_sep = ' ' + }, + lineinfo = { + provider = 'position', + hl = {fg = colors.fg}, + right_sep = ' ' + }, + percent = { + provider = 'line_percentage', + hl = {fg = colors.fg, style = 'bold'}, + right_sep = ' ' + }, + diagerr = { + provider = 'diagnostic_errors', + icon = ' ', + hl = {fg = colors.red}, + right_sep = ' ' + }, + diagwarn = { + provider = 'diagnostic_warnings', + icon = ' ', + hl = {fg = colors.yellow}, + right_sep = ' ' + }, + diaghint = { + provider = 'diagnostic_hints', + icon = ' ', + hl = {fg = colors.cyan}, + right_sep = ' ' + }, + diaginfo = { + provider = 'diagnostic_info', + icon = ' ', + hl = {fg = colors.blue} + }, + lspclient = { + provider = 'lsp_client_names', icon = ' LSP:', - highlight = {colors.purple, colors.grey1, 'bold'} - } - } - - gls.right[2] = { - FileEncode = { - provider = 'FileEncode', - condition = condition.hide_in_width, - separator = ' ', - separator_highlight = {'NONE', colors.grey1}, - highlight = {colors.fg, colors.grey1} - } - } - - gls.right[3] = { - FileFormat = { - provider = 'FileFormat', - condition = condition.hide_in_width, - separator = ' ', - separator_highlight = {'NONE', colors.grey1}, - highlight = {colors.fg, colors.grey1} - } - } - - gls.right[4] = { - GitIcon = { - provider = function() return '  ' end, - condition = condition.check_git_workspace, - separator = ' ', - separator_highlight = {'NONE', colors.grey1}, - highlight = {colors.green, colors.grey1, 'bold'} - } - } - - gls.right[5] = { - GitBranch = { - provider = 'GitBranch', - condition = condition.check_git_workspace, - highlight = {colors.green, colors.grey1, 'bold'} - } - } - - gls.right[6] = { - GitSeparator = { - provider = function() - return ' ' - end, - highlight = {colors.green, colors.grey1} - } - } - - gls.right[7] = { - DiffAdd = { - provider = 'DiffAdd', - condition = condition.hide_in_width, + hl = {fg = colors.purple, style = 'bold'} + }, + format = { + provider = file_osinfo, + hl = {fg = colors.cyan}, + left_sep = ' ' + }, + encode = { + provider = 'file_encoding', + hl = {fg = colors.fg}, + left_sep = ' ' + }, + filetype = { + provider = 'file_type', + hl = {fg = colors.blue, style = 'bold'}, + left_sep = ' ' + }, + gitbranch = { + provider = 'git_branch', + icon = ' ', + hl = {fg = colors.green, style = 'bold'}, + left_sep = ' ' + }, + diffadd = { + provider = 'git_diff_added', icon = ' ', - highlight = {colors.green, colors.grey1} - } - } - - gls.right[8] = { - DiffModified = { - provider = 'DiffModified', - condition = condition.hide_in_width, + hl = {fg = colors.green}, + left_sep = ' ' + }, + diffchange = { + provider = 'git_diff_changed', icon = '柳', - highlight = {colors.yellow, colors.grey1} - } - } - - gls.right[9] = { - DiffRemove = { - provider = 'DiffRemove', - condition = condition.hide_in_width, + hl = {fg = colors.yellow}, + left_sep = ' ' + }, + diffremove = { + provider = 'git_diff_removed', icon = ' ', - highlight = {colors.red, colors.grey1} + hl = {fg = colors.red}, + left_sep = ' ' } } - gls.short_line_left[1] = { - BufferType = { - provider = 'FileTypeName', - separator = ' ', - separator_highlight = {'NONE', colors.grey1}, - highlight = {colors.blue, colors.grey1, 'bold'} - } + -- Initialize the components table before defining it + local components = { + active = {}, + inactive = {} } - gls.short_line_left[2] = { - SFileName = { - provider = 'SFileName', - condition = condition.buffer_not_empty, - highlight = {colors.fg, colors.grey1, 'bold'} - } - } + table.insert(components.active, {}) + table.insert(components.active, {}) + table.insert(components.active, {}) + table.insert(components.inactive, {}) + table.insert(components.inactive, {}) - gls.short_line_right[1] = { - BufferIcon = { - provider= 'BufferIcon', - highlight = {colors.fg, colors.grey1} + table.insert(components.active[1], comps.dummy) + table.insert(components.active[1], comps.vi_mode) + table.insert(components.active[1], comps.filesize) + table.insert(components.active[1], comps.fileinfo) + table.insert(components.active[1], comps.lineinfo) + table.insert(components.active[1], comps.percent) + table.insert(components.active[1], comps.diagerr) + table.insert(components.active[1], comps.diagwarn) + table.insert(components.active[1], comps.diaghint) + table.insert(components.active[1], comps.diaginfo) + table.insert(components.active[3], comps.lspclient) + table.insert(components.active[3], comps.format) + table.insert(components.active[3], comps.encode) + table.insert(components.active[3], comps.filetype) + table.insert(components.active[3], comps.gitbranch) + table.insert(components.active[3], comps.diffadd) + table.insert(components.active[3], comps.diffchange) + table.insert(components.active[3], comps.diffremove) + table.insert(components.inactive[1], comps.dummy) + table.insert(components.inactive[1], comps.fileinfo) + table.insert(components.inactive[2], comps.filetype) + + require('feline').setup { + colors = {bg = colors.grey1, fg = colors.fg}, + components = components, + vi_mode_colors = vi_mode_colors, + force_inactive = { + filetypes = { + 'packer', + 'NvimTree', + 'alpha', + 'undotree', + 'DIFF', + 'Outline' + }, + buftypes = {'terminal', 'nofile'}, + bufnames = {} } } end @@ -358,10 +324,8 @@ end function M.nvimtree_conf() vim.g.nvim_tree_width = 35 vim.g.nvim_tree_ignore = {'.git', '.hg', '.svn', 'node_modules'} - vim.g.nvim_tree_auto_open = 0 - vim.g.nvim_tree_auto_close = 1 vim.g.nvim_tree_auto_ignore_ft = {'dashboard'} - vim.g.nvim_tree_follow = 1 + vim.g.nvim_tree_respect_buf_cwd = 1 vim.g.nvim_tree_indent_markers = 1 vim.g.nvim_tree_git_hl = 1 vim.g.nvim_tree_auto_resize = 0 @@ -452,7 +416,7 @@ function M.gitsigns_conf() ['o ih'] = ':lua require"gitsigns.actions".select_hunk()', ['x ih'] = ':lua require"gitsigns.actions".select_hunk()' }, - watch_index = { + watch_gitdir = { interval = 1000, follow_files = true }, diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index a43744f..b96d149 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -29,9 +29,8 @@ return require('packer').startup( event = 'VimEnter', config = ui.dashboard_conf } - use { -- TODO: consider moving to feline.nvim - 'glepnir/galaxyline.nvim', - branch = 'main', + use { + 'famiu/feline.nvim', wants = 'nvim-web-devicons', config = ui.statusline_conf } @@ -43,7 +42,16 @@ return require('packer').startup( use { 'kyazdani42/nvim-tree.lua', cmd = 'NvimTreeToggle', - setup = ui.nvimtree_conf + setup = ui.nvimtree_conf, + -- FIX: when all the options are migrated to setup() + config = function() + require('nvim-tree').setup { + open_on_setup = false, + auto_close = true, + hijack_cursor = true, + update_cwd = true + } + end } use { 'folke/which-key.nvim', @@ -137,6 +145,11 @@ return require('packer').startup( run = 'cargo build --release', ft = {'clojure', 'lisp', 'scheme', 'fennel'} } + use { + 'ahmedkhalf/project.nvim', + event = 'BufEnter', + config = editor.project_conf + } --------- -- LSP -- @@ -155,10 +168,6 @@ return require('packer').startup( wants = 'nvim-lspconfig', config = lsp.sqls_conf } - use { - 'ahmedkhalf/lsp-rooter.nvim', - after = 'nvim-lspconfig' - } use { 'folke/trouble.nvim', cmd = {'Trouble', 'TroubleToggle', 'TroubleRefresh'}, @@ -245,7 +254,7 @@ return require('packer').startup( -- Tools -- ----------- local tools = require('modules.tools') - use { + use { -- TODO: watch out for fzf-lua 'nvim-telescope/telescope.nvim', cmd = 'Telescope', wants = { @@ -359,10 +368,11 @@ return require('packer').startup( event = 'WinScrolled', config = tools.neoscroll_conf } - use { -- TODO: colors + config + use { 'michaelb/sniprun', run = 'bash ./install.sh 1', - cmd = 'SnipRun' + cmd = 'SnipRun', + config = tools.sniprun_conf } use { 'NTBBloodbath/rest.nvim', @@ -382,6 +392,6 @@ return require('packer').startup( } use {'tweekmonster/startuptime.vim', cmd = 'StartupTime'} -- Just for benchmarking - -- TODO: dial.nvim, rust-tools.nvim, crates.nvim, go.nvim, clojure-vim/*, vim-pandoc + -- TODO: dial.nvim, rust-tools.nvim, crates.nvim, go.nvim, clojure-vim/*, vim-pandoc, nvim-bqf end )