Skip to content

Commit 0ae1923

Browse files
committed
Update neovim configs
1 parent 16518d9 commit 0ae1923

6 files changed

Lines changed: 66 additions & 71 deletions

File tree

.config/nvim/init.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ require('packer').startup(function(use)
4444
use 'nvim-treesitter/nvim-treesitter' -- Highlight, edit, and navigate code
4545
use 'nvim-treesitter/nvim-treesitter-textobjects' -- Additional textobjects for treesitter
4646
use 'folke/which-key.nvim' -- View possible keybindings
47+
use 'tpope/vim-abolish' -- :Subvert et al
48+
use 'tpope/vim-eunuch' -- :Move, :Rename et al
4749

4850
-- Linting, formatting
4951
use 'jose-elias-alvarez/null-ls.nvim' -- Linters, formatters
@@ -54,7 +56,6 @@ require('packer').startup(function(use)
5456
use 'neovim/nvim-lspconfig' -- Collection of configurations for built-in LSP client
5557
use 'folke/lsp-colors.nvim' -- LSP colors
5658
use 'folke/trouble.nvim' -- Show LSP diagnostics inline and in a dedicated window
57-
use 'kaputi/e-kaput.nvim' -- LSP diagnostics in floating window
5859

5960
use 'hrsh7th/cmp-nvim-lsp'
6061
use 'hrsh7th/cmp-buffer'

.config/nvim/lua/config.lua

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
-- General options
2-
vim.o.number = true -- always show line numbers
3-
vim.o.backspace = 'indent,eol,start' -- backspace on everything
4-
vim.o.encoding = 'utf-8' -- default encoding for all files
5-
vim.o.showcmd = true -- display incomplete commands
6-
vim.o.showmode = true -- show current mode
7-
vim.o.autoread = true -- Reload files changed outside vim
8-
vim.o.laststatus = 2 -- Always show the status line
2+
vim.o.number = true -- always show line numbers
3+
vim.o.backspace = 'indent,eol,start' -- backspace on everything
4+
vim.o.encoding = 'utf-8' -- default encoding for all files
5+
vim.o.showcmd = true -- display incomplete commands
6+
vim.o.showmode = true -- show current mode
7+
vim.o.autoread = true -- Reload files changed outside vim
8+
vim.o.laststatus = 2 -- Always show the status line
99
vim.o.signcolumn = 'yes'
1010

1111
-- Tab settings
@@ -20,17 +20,17 @@ vim.o.smartindent = true
2020
vim.o.smarttab = true
2121

2222
-- Searching
23-
vim.o.hlsearch = true -- highlight searches
24-
vim.o.incsearch = true -- incremental search
25-
vim.o.ignorecase = true -- searches are case insensitive...
26-
vim.o.smartcase = true -- ... unless they contain at least one capital letter
23+
vim.o.hlsearch = true -- highlight searches
24+
vim.o.incsearch = true -- incremental search
25+
vim.o.ignorecase = true -- searches are case insensitive...
26+
vim.o.smartcase = true -- ... unless they contain at least one capital letter
2727

2828
-- Whitespace
29-
vim.o.wrap = false -- don't wrap lines
30-
vim.o.linebreak = true -- wrap lines at convenient places
29+
vim.o.wrap = false -- don't wrap lines
30+
vim.o.linebreak = true -- wrap lines at convenient places
3131

3232
-- Scrolling
33-
vim.o.scrolloff = 2 -- start scrolling when we're 2 lines away from margins
33+
vim.o.scrolloff = 2 -- start scrolling when we're 2 lines away from margins
3434

3535
-- Turn off Swap Files
3636
vim.o.swapfile = false
@@ -44,7 +44,7 @@ vim.o.mouse = 'a'
4444
vim.o.guifont = 'FiraCode Nerd Font:h13'
4545

4646
FONT_SIZE = 13
47-
CHANGE_GUI_FONT_SIZE = function(delta)
47+
ChangeGuiFontSize = function(delta)
4848
if delta == 0 then
4949
FONT_SIZE = 13
5050
end

.config/nvim/lua/keymaps.lua

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
local opts = { noremap = true, silent = true }
2-
local term_opts = { silent = true }
1+
local opts = function (desc)
2+
return { noremap = true, silent = true, desc = desc }
3+
end
34

45
local keymap = vim.api.nvim_set_keymap
56

67
-- Remap <Space> as leader key
7-
keymap('', '<Space>', '<Nop>', opts)
8+
keymap('', '<Space>', '<Nop>', opts())
89
vim.g.mapleader = ' '
910
vim.g.maplocalleader = ' '
1011

@@ -16,49 +17,54 @@ vim.g.maplocalleader = ' '
1617
-- term_mode = "t"
1718
-- command_mode = "c"
1819

20+
-- Save
21+
keymap('n', '<D-space>', '<cmd> w<CR>', opts('Save document'))
22+
1923
-- New Tab
20-
keymap('n', '<Leader>tt', '<cmd> tabnew<CR>', opts)
21-
keymap('n', '<D-t>', '<cmd> tabnew<CR>', opts) -- FIXME: Crutch, remove in favour of <Leader>tt
24+
keymap('n', '<Leader>tt', '<cmd> tabnew<CR>', opts('New tab'))
25+
keymap('n', '<D-t>', '<cmd> tabnew<CR>', opts('New tab')) -- FIXME: Crutch, remove in favour of <Leader>tt
2226

2327
-- Set wrap / unwrap
24-
keymap('n', '<Leader>ww', '<cmd> set wrap!<CR>', opts)
28+
keymap('n', '<Leader>ww', '<cmd> set wrap!<CR>', opts('Toggle text wrapping'))
2529

2630
-- Session (CWD session.vim) management
27-
keymap('n', '<Leader>sc', '<cmd> mksession! session.vim<CR>', opts)
28-
keymap('n', '<Leader>sr', '<cmd> source session.vim<CR>', opts)
31+
keymap('n', '<Leader>sc', '<cmd> mksession! session.vim<CR>', opts('Write current session to ./session.vim'))
32+
keymap('n', '<Leader>sr', '<cmd> source session.vim<CR>', opts('Restore session from ./session.vim'))
2933

3034
-- LSP
31-
keymap('n', '<Leader>lr', '<cmd> LspRestart<CR>', opts)
32-
keymap('n', '<Leader>le', '<cmd> TroubleToggle document_diagnostics<CR>', opts)
33-
keymap('n', '<Leader>lw', '<cmd> TroubleToggle workspace_diagnostics<CR>', opts)
35+
keymap('n', '<Leader>lr', '<cmd> LspRestart<CR>', opts('Restart LSP server'))
36+
keymap('n', '<Leader>le', '<cmd> TroubleToggle document_diagnostics<CR>', opts('Toggle document diagnostic messages'))
37+
keymap('n', '<Leader>lw', '<cmd> TroubleToggle workspace_diagnostics<CR>', opts('Toggle workspace diagnostic messages'))
38+
keymap('n', '<Leader>lf', '<cmd> lua vim.lsp.buf.format()<CR>', opts('Format current file with null-ls'))
39+
-- vim.keymap.set('n', '<leader>lf', vim.lsp.buf.format, opts)
3440

3541
-- telescope
36-
keymap('n', '<C-p>', '<cmd> Telescope find_files<CR>', opts) -- FIXME: Crutch, remove in favour of <Leader>ff
37-
keymap('n', '<Leader>ff', '<cmd> Telescope find_files<CR>', opts)
38-
keymap('n', '<Leader>fw', '<cmd> Telescope live_grep<CR>', opts)
42+
keymap('n', '<C-p>', '<cmd> Telescope find_files<CR>', opts('Find files in current workspace')) -- FIXME: Crutch, remove in favour of <Leader>ff
43+
keymap('n', '<Leader>ff', '<cmd> Telescope find_files<CR>', opts('Find files in current workspace'))
44+
keymap('n', '<Leader>fw', '<cmd> Telescope live_grep<CR>', opts('Find search term in files in current workspace'))
3945

4046
-- trouble
4147

4248
-- Cursor movement with cmd key (Mac OS)
43-
keymap('n', '<D-left>', 'b', opts)
44-
keymap('i', '<D-left>', 'b', opts)
45-
keymap('n', '<D-right>', 'w', opts)
46-
keymap('i', '<D-right>', 'w', opts)
49+
keymap('n', '<D-left>', 'b', opts('motion: b'))
50+
keymap('i', '<D-left>', 'b', opts('motion: b'))
51+
keymap('n', '<D-right>', 'w', opts('motion: w'))
52+
keymap('i', '<D-right>', 'w', opts('motion: w'))
4753

4854
-- Arrow navigation in command line
4955
-- cnoremap <C-P> <Up>
5056
-- cnoremap <C-N> <Down>
51-
keymap('c', '<C-P>', '<Up>', opts)
52-
keymap('c', '<C-N>', '<Down>', opts)
57+
-- keymap('c', '<C-P>', '<Up>', opts)
58+
-- keymap('c', '<C-N>', '<Down>', opts)
5359

5460
-- increase / decrease / reset font size
55-
vim.keymap.set({ 'n', 'i' }, '<D-=>', function() CHANGE_GUI_FONT_SIZE(1) end, opts)
56-
vim.keymap.set({ 'n', 'i' }, '<D-->', function() CHANGE_GUI_FONT_SIZE(-1) end, opts)
57-
vim.keymap.set({ 'n', 'i' }, '<D-0>', function() CHANGE_GUI_FONT_SIZE(0) end, opts)
61+
vim.keymap.set({ 'n', 'i' }, '<D-=>', function() ChangeGuiFontSize(1) end, opts())
62+
vim.keymap.set({ 'n', 'i' }, '<D-->', function() ChangeGuiFontSize(-1) end, opts())
63+
vim.keymap.set({ 'n', 'i' }, '<D-0>', function() ChangeGuiFontSize(0) end, opts())
5864

5965
-- Allow clipboard copy paste in neovim
6066
vim.g.neovide_input_use_logo = 1
61-
keymap('', '<D-v>', '+p<CR>', opts)
62-
keymap('!', '<D-v>', '<C-R>+', opts)
63-
keymap('t', '<D-v>', '<C-R>+', opts)
64-
keymap('v', '<D-v>', '<C-R>+', opts)
67+
keymap('', '<D-v>', '+p<CR>', opts())
68+
keymap('!', '<D-v>', '<C-R>+', opts())
69+
keymap('t', '<D-v>', '<C-R>+', opts())
70+
keymap('v', '<D-v>', '<C-R>+', opts())

.config/nvim/lua/plugins/lsp.lua

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,12 @@ vim.diagnostic.config {
4141
-- prefix = "",
4242
-- },
4343
float = true,
44-
-- float = {
45-
-- border = 'round',
46-
-- },
4744
signs = true,
4845
underline = true,
4946
update_in_insert = false,
5047
}
5148

5249
vim.o.updatetime = 200 -- default is 4000
53-
require('e-kaput').setup({
54-
-- defaults
55-
enabled = true, -- true | false, Enable EKaput.
56-
transparency = 25, -- 0 - 100 , transparecy percentage.
57-
borders = true, -- true | false, Borders.
58-
error_sign = '', -- Error sign.
59-
warning_sign = '', -- Warning sign.
60-
information_sign = '', -- Information sign.
61-
hint_sign = '', -- Hint sign
62-
})
6350

6451
local lsp_defaults = {
6552
flags = {
@@ -70,7 +57,7 @@ local lsp_defaults = {
7057
),
7158
on_attach = function(client, bufnr)
7259
vim.api.nvim_exec_autocmds('User', { pattern = 'LspAttached' })
73-
-- vim.api.nvim_command('autocmd CursorHold <buffer> lua vim.lsp.util.show_line_diagnostics()')
60+
vim.api.nvim_command('autocmd CursorHold <buffer> lua vim.diagnostic.open_float(nil, { focusable = false })')
7461
end
7562
}
7663

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins
22

3-
local autogroup = vim.api.nvim_create_augroup('LspFormatting', {})
3+
-- local autogroup = vim.api.nvim_create_augroup('LspFormatting', {})
44

55
require('null-ls').setup({
66
sources = {
77
-- Bash
88
require('null-ls').builtins.diagnostics.shellcheck,
99

1010
-- Lua
11-
require("null-ls").builtins.formatting.stylua,
11+
-- require("null-ls").builtins.formatting.stylua,
1212

1313
-- JS, TS, JSON
1414
require("null-ls").builtins.diagnostics.eslint,
@@ -24,16 +24,16 @@ require('null-ls').setup({
2424
-- require("null-ls").builtins.completion.spell,
2525
},
2626

27-
on_attach = function(client, bufnr)
28-
if client.supports_method('textDocument/formatting') then
29-
vim.api.nvim_clear_autocmds({ group = autogroup, buffer = bufnr })
30-
vim.api.nvim_create_autocmd('BufWritePre', {
31-
group = autogroup,
32-
buffer = bufnr,
33-
callback = function()
34-
vim.lsp.buf.format({ bufnr = bufnr })
35-
end,
36-
})
37-
end
38-
end
27+
-- on_attach = function(client, bufnr)
28+
-- if client.supports_method('textDocument/formatting') then
29+
-- vim.api.nvim_clear_autocmds({ group = autogroup, buffer = bufnr })
30+
-- vim.api.nvim_create_autocmd('BufWritePre', {
31+
-- group = autogroup,
32+
-- buffer = bufnr,
33+
-- callback = function()
34+
-- vim.lsp.buf.format({ bufnr = bufnr })
35+
-- end,
36+
-- })
37+
-- end
38+
-- end
3939
})

.config/nvim/lua/plugins/nvim-treesitter.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ require('nvim-treesitter.configs').setup({
1111
'glsl',
1212
'go',
1313
'graphql',
14+
'hcl',
1415
'html',
1516
'javascript',
1617
'json',

0 commit comments

Comments
 (0)