diff --git a/bash/.bashrc b/bash/.bashrc index ce19e6f..77fd228 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -5,8 +5,11 @@ # Add ~/bin and ~/bin/scripts to my path export PATH=$PATH:$HOME/bin/:$HOME/bin/scripts/ +NEOVIDE_COMMAND="env WINIT_UNIX_BACKEND=x11 neovide --multigrid" + # Set editor to neovim. -export EDITOR=nvim +alias neovide=$NEOVIDE_COMMAND +export EDITOR=$NEOVIDE_COMMAND # Prompt stuff # diff --git a/nvim/init.lua b/nvim/init.lua index ba28d88..6abfd8d 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -24,18 +24,13 @@ vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'} vim.opt.shortmess = vim.opt.shortmess + { c = true} vim.api.nvim_set_option('updatetime', 100) --- Fixed column for diagnostics to appear --- Show autodiagnostic popup on cursor hover_range --- Goto previous / next diagnostic warning / error --- Show inlay_hints more frequently +-- Always show signcolumn vim.cmd([[ set signcolumn=yes -autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) ]]) -- Load utilities require('kalle.utils') - -- Load plugins require('kalle.plugins') diff --git a/nvim/lua/kalle/config/init.lua b/nvim/lua/kalle/config/init.lua index 19f848c..ccdc986 100644 --- a/nvim/lua/kalle/config/init.lua +++ b/nvim/lua/kalle/config/init.lua @@ -1,2 +1,3 @@ require('kalle.config.keybinds') +require('kalle.config.neovide') require('kalle.config.plugin-config') diff --git a/nvim/lua/kalle/config/neovide.lua b/nvim/lua/kalle/config/neovide.lua new file mode 100644 index 0000000..f010d45 --- /dev/null +++ b/nvim/lua/kalle/config/neovide.lua @@ -0,0 +1,10 @@ +vim.cmd [[ + set guifont=Fira\ Code\ Nerd\ Font:h11 + let g:neovide_transparency = 0.8 + let g:neovide_floating_blur_amount_x = 2.0 + let g:neovide_floating_blur_amount_y = 2.0 + let g:neovide_scroll_animation_length = 0.1 + let g:neovide_refresh_rate = 144 + let g:neovide_fullscreen = v:false + let g:neovide_cursor_animation_length=0.05 +]] diff --git a/nvim/lua/kalle/config/plugin-config.lua b/nvim/lua/kalle/config/plugin-config.lua deleted file mode 100644 index 69d3c0e..0000000 --- a/nvim/lua/kalle/config/plugin-config.lua +++ /dev/null @@ -1,289 +0,0 @@ -require('which-key').setup {} - -require('nvim-tree').setup { - sort_by = 'case_sensitive', - view = { - adaptive_size = true, - mappings = { - custom_only = false, - list = {}, - }, - }, - renderer = { - group_empty = true, - highlight_git = true, - highlight_opened_files = "name", - indent_markers = { - enable = true, - }, - }, - filters = { - dotfiles = true, - }, -} - -require('neogit').setup {} - -require('lualine').setup {} - -require('bufferline').setup { - options = { - mode = 'buffers', - numbers = 'ordinal', - separator_style = 'slant', - show_buffer_icons = true, - show_buffer_close_icons = false, - show_close_icon = false, - always_show_bufferline = true, - right_mouse_command = function(bufnum) end, - middle_mouse_command = function(bufnum) - require('bufdelete').bufdelete(bufnum) - end, - custom_areas = { - right = function() - local result = {} - local seve = vim.diagnostic.severity - local error = #vim.diagnostic.get(0, {severity = seve.ERROR}) - local warning = #vim.diagnostic.get(0, {severity = seve.WARN}) - local info = #vim.diagnostic.get(0, {severity = seve.INFO}) - local hint = #vim.diagnostic.get(0, {severity = seve.HINT}) - - if error ~= 0 then - table.insert(result, {text = "  " .. error, fg = "#EC5241"}) - end - - if warning ~= 0 then - table.insert(result, {text = "  " .. warning, fg = "#EFB839"}) - end - - if hint ~= 0 then - table.insert(result, {text = "  " .. hint, fg = "#A3BA5E"}) - end - - if info ~= 0 then - table.insert(result, {text = "  " .. info, fg = "#7EA9A7"}) - end - return result - end, - }, - offsets = { - { - filetype = "NvimTree", - text = function() - return vim.fn.getcwd() - end, - highlight = "Directory", - text_align = "left" - } - } - } -} - -local cmp = require'cmp' - -cmp.setup({ - snippet = { - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), - -- Add tab support - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.close(), - [''] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Insert, - select = true, - }) - }), - sources = cmp.config.sources({ - { name = 'path' }, -- file paths - { name = 'nvim_lsp', keyword_length = 3 }, -- from language server - { name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized - { name = 'nvim_lua', keyword_length = 2}, -- complete neovim's Lua runtime API such vim.lsp.* - { name = 'buffer', keyword_length = 2 }, -- source current buffer - { name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip - { name = 'calc'}, -- source for math calculation - { name = 'nvim_lsp' }, - }), - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - formatting = { - fields = {'menu', 'abbr', 'kind'}, - format = function(entry, item) - local menu_icon ={ - nvim_lsp = 'λ', - vsnip = '⋗', - buffer = 'Ω', - path = '🖫', - } - item.menu = menu_icon[entry.source.name] - return item - end, - }, -}) - -cmp.setup.filetype('gitcommit', { - sources = cmp.config.sources({ - { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. - }, { - { name = 'buffer' }, - }) -}) - --- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline('/', { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = 'buffer' } - } -}) - --- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline(':', { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }) -}) - --- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers.. -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) - -require("mason").setup() -require("mason-lspconfig").setup() -require("mason-lspconfig").setup_handlers({ - function (server_name) -- default handler (optional) - if server_name == 'sumneko_lua' then - require("lspconfig")[server_name].setup { - capabilities = capabilities, - settings = { - Lua = { - diagnostics = { - globals = {'vim'} - }, - runtime = { - version = "LuaJIT", - path = vim.split(package.path, ";") - }, - workspace = { - library = { - [vim.fn.expand("$VIMRUNTIME/lua")] = true, - [vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true - } - } - } - }, - } - else - require("lspconfig")[server_name].setup { - capabilities = capabilities, - } - end - end, -}) - -require('mason-nvim-dap').setup() - -require('gitsigns').setup { - current_line_blame = true, -} - -require('marks').setup {} - -require('nvim-treesitter.configs').setup { - ensure_installed = { "lua", "rust", "toml" }, - auto_install = true, - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - }, - indent = { - enable = true - }, - rainbow = { - enable = true, - extended_mode = true, - max_file_lines = nil, - } -} - --- Treesitter folding -vim.wo.foldmethod = 'expr' -vim.wo.foldexpr = 'nvim_treesitter#foldexpr()' -vim.o.foldenable = false - -require('Comment').setup() -require('illuminate').configure() - - -local rt_config = { - server = { - settings = { - on_attach = function(_, bufnr) - -- Hover actions - vim.keymap.set("n", "", rt_config.hover_actions.hover_actions, { buffer = bufnr }) - -- Code action groups - vim.keymap.set("n", "a", rt_config.code_action_group.code_action_group, { buffer = bufnr }) - require 'illuminate'.on_attach(client) - end, - ["rust-analyzer"] = { - checkOnSave = { - command = "clippy" - }, - }, - } - }, -} - -require('rust-tools').setup() - --- LSP Diagnostics Options Setup -local sign = function(opts) - vim.fn.sign_define(opts.name, { - texthl = opts.name, - text = opts.text, - numhl = '' - }) -end - -sign({name = 'DiagnosticSignError', text = ''}) -sign({name = 'DiagnosticSignWarn', text = ''}) -sign({name = 'DiagnosticSignHint', text = ''}) -sign({name = 'DiagnosticSignInfo', text = ''}) - -vim.diagnostic.config({ - virtual_text = false, - signs = true, - update_in_insert = true, - underline = true, - severity_sort = false, - float = { - border = 'rounded', - source = 'always', - header = '', - prefix = '', - }, -}) - -vim.cmd([[ -set signcolumn=yes -autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) -]]) - -require('nvim-lightbulb').setup({autocmd = {enabled = true}}) - -require("telescope").load_extension("ui-select") - -require("todo-comments").setup {} diff --git a/nvim/lua/kalle/config/plugin-config/bufferline.lua b/nvim/lua/kalle/config/plugin-config/bufferline.lua new file mode 100644 index 0000000..0e0cdf6 --- /dev/null +++ b/nvim/lua/kalle/config/plugin-config/bufferline.lua @@ -0,0 +1,52 @@ +require('bufferline').setup { + options = { + mode = 'buffers', + numbers = 'ordinal', + separator_style = 'slant', + show_buffer_icons = true, + show_buffer_close_icons = false, + show_close_icon = false, + always_show_bufferline = true, + right_mouse_command = function(bufnum) end, + middle_mouse_command = function(bufnum) + require('bufdelete').bufdelete(bufnum) + end, + custom_areas = { + right = function() + local result = {} + local seve = vim.diagnostic.severity + local error = #vim.diagnostic.get(0, {severity = seve.ERROR}) + local warning = #vim.diagnostic.get(0, {severity = seve.WARN}) + local info = #vim.diagnostic.get(0, {severity = seve.INFO}) + local hint = #vim.diagnostic.get(0, {severity = seve.HINT}) + + if error ~= 0 then + table.insert(result, {text = "  " .. error, fg = "#EC5241"}) + end + + if warning ~= 0 then + table.insert(result, {text = "  " .. warning, fg = "#EFB839"}) + end + + if hint ~= 0 then + table.insert(result, {text = "  " .. hint, fg = "#A3BA5E"}) + end + + if info ~= 0 then + table.insert(result, {text = "  " .. info, fg = "#7EA9A7"}) + end + return result + end, + }, + offsets = { + { + filetype = "NvimTree", + text = function() + return vim.fn.getcwd() + end, + highlight = "Directory", + text_align = "left" + } + } + } +} diff --git a/nvim/lua/kalle/config/plugin-config/cmp.lua b/nvim/lua/kalle/config/plugin-config/cmp.lua new file mode 100644 index 0000000..3edf987 --- /dev/null +++ b/nvim/lua/kalle/config/plugin-config/cmp.lua @@ -0,0 +1,82 @@ +local cmp = require'cmp' + +cmp.setup({ + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + -- Add tab support + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }) + }), + sources = cmp.config.sources({ + { name = 'path' }, -- file paths + { name = 'nvim_lsp', keyword_length = 3 }, -- from language server + { name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized + { name = 'nvim_lua', keyword_length = 2}, -- complete neovim's Lua runtime API such vim.lsp.* + { name = 'buffer', keyword_length = 2 }, -- source current buffer + { name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip + { name = 'calc'}, -- source for math calculation + { name = 'nvim_lsp' }, + }), + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + formatting = { + fields = {'menu', 'abbr', 'kind'}, + format = function(entry, item) + local menu_icon ={ + nvim_lsp = 'λ', + vsnip = '⋗', + buffer = 'Ω', + path = '🖫', + } + item.menu = menu_icon[entry.source.name] + return item + end, + }, +}) + +cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. + }, { + { name = 'buffer' }, + }) +}) + +-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline('/', { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } +}) + +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) +}) + +-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers.. +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) + diff --git a/nvim/lua/kalle/config/plugin-config/init.lua b/nvim/lua/kalle/config/plugin-config/init.lua new file mode 100644 index 0000000..b414bba --- /dev/null +++ b/nvim/lua/kalle/config/plugin-config/init.lua @@ -0,0 +1,21 @@ +require('kalle.config.plugin-config.lsp') +require('kalle.config.plugin-config.cmp') +require('kalle.config.plugin-config.treesitter') +require('kalle.config.plugin-config.bufferline') +require('kalle.config.plugin-config.nvim-tree') + +require('which-key').setup {} +require('neogit').setup {} +require('lualine').setup {} +require('marks').setup {} +require('Comment').setup() +require('illuminate').configure() +require("telescope").load_extension("ui-select") +require("todo-comments").setup {} + +require('gitsigns').setup { + current_line_blame = true, +} + + + diff --git a/nvim/lua/kalle/config/plugin-config/lsp.lua b/nvim/lua/kalle/config/plugin-config/lsp.lua new file mode 100644 index 0000000..cf3672a --- /dev/null +++ b/nvim/lua/kalle/config/plugin-config/lsp.lua @@ -0,0 +1,91 @@ +require("mason").setup() +require("mason-lspconfig").setup() +require("mason-lspconfig").setup_handlers({ + function (server_name) -- default handler (optional) + if server_name == 'sumneko_lua' then + require("lspconfig")[server_name].setup { + capabilities = capabilities, + settings = { + Lua = { + diagnostics = { + globals = {'vim'} + }, + runtime = { + version = "LuaJIT", + path = vim.split(package.path, ";") + }, + workspace = { + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true + } + } + } + }, + } + else + require("lspconfig")[server_name].setup { + capabilities = capabilities, + } + end + end, +}) + +require('mason-nvim-dap').setup() + + +local rt_config = { + server = { + settings = { + on_attach = function(_, bufnr) + -- Hover actions + vim.keymap.set("n", "", rt_config.hover_actions.hover_actions, { buffer = bufnr }) + -- Code action groups + vim.keymap.set("n", "a", rt_config.code_action_group.code_action_group, { buffer = bufnr }) + require 'illuminate'.on_attach(client) + end, + ["rust-analyzer"] = { + checkOnSave = { + command = "clippy" + }, + }, + } + }, +} + +require('rust-tools').setup(rt_config) + +-- LSP Diagnostics Options Setup +local sign = function(opts) + vim.fn.sign_define(opts.name, { + texthl = opts.name, + text = opts.text, + numhl = '' + }) +end + +sign({name = 'DiagnosticSignError', text = ''}) +sign({name = 'DiagnosticSignWarn', text = ''}) +sign({name = 'DiagnosticSignHint', text = ''}) +sign({name = 'DiagnosticSignInfo', text = ''}) + +vim.diagnostic.config({ + virtual_text = false, + signs = true, + update_in_insert = true, + underline = true, + severity_sort = false, + float = { + border = 'rounded', + source = 'always', + header = '', + prefix = '', + }, +}) + +vim.cmd([[ +autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) +]]) + + +require('nvim-lightbulb').setup({autocmd = {enabled = true}}) diff --git a/nvim/lua/kalle/config/plugin-config/nvim-tree.lua b/nvim/lua/kalle/config/plugin-config/nvim-tree.lua new file mode 100644 index 0000000..b2992a4 --- /dev/null +++ b/nvim/lua/kalle/config/plugin-config/nvim-tree.lua @@ -0,0 +1,21 @@ +require('nvim-tree').setup { + sort_by = 'case_sensitive', + view = { + adaptive_size = true, + mappings = { + custom_only = false, + list = {}, + }, + }, + renderer = { + group_empty = true, + highlight_git = true, + highlight_opened_files = "name", + indent_markers = { + enable = true, + }, + }, + filters = { + dotfiles = true, + }, +} diff --git a/nvim/lua/kalle/config/plugin-config/treesitter.lua b/nvim/lua/kalle/config/plugin-config/treesitter.lua new file mode 100644 index 0000000..9ba6223 --- /dev/null +++ b/nvim/lua/kalle/config/plugin-config/treesitter.lua @@ -0,0 +1,21 @@ +require('nvim-treesitter.configs').setup { + ensure_installed = { "lua", "rust", "toml" }, + auto_install = true, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + indent = { + enable = true + }, + rainbow = { + enable = true, + extended_mode = true, + max_file_lines = nil, + } +} + +-- Treesitter folding +vim.wo.foldmethod = 'expr' +vim.wo.foldexpr = 'nvim_treesitter#foldexpr()' +vim.o.foldenable = false