nvim: clean up lua init
This commit is contained in:
parent
c2abcf4f3e
commit
c599929e4f
28
.gitmodules
vendored
28
.gitmodules
vendored
@ -1,3 +1,6 @@
|
||||
################
|
||||
# note-taking setup
|
||||
################
|
||||
[submodule "src/.local/bin/pyinstantref"]
|
||||
path = src/.local/bin/pyinstantref
|
||||
url = https://github.com/dogeystamp/pyinstantref
|
||||
@ -5,6 +8,12 @@
|
||||
path = src/.local/bin/inkscape-shortcut-manager
|
||||
url = https://github.com/dogeystamp/inkscape-shortcut-manager
|
||||
|
||||
|
||||
|
||||
################
|
||||
# neovim plugins
|
||||
################
|
||||
|
||||
# prompts
|
||||
# telescope.vim
|
||||
[submodule "src/.local/share/nvim/site/pack/3pp/start/telescope.nvim"]
|
||||
@ -32,12 +41,6 @@
|
||||
path = src/.local/share/nvim/site/pack/3pp/start/vim-gitgutter
|
||||
url = https://github.com/airblade/vim-gitgutter.git
|
||||
|
||||
# error/warning/info box
|
||||
# coding.vim
|
||||
[submodule "src/.local/share/nvim/site/pack/3pp/start/trouble.nvim"]
|
||||
path = src/.local/share/nvim/site/pack/3pp/start/trouble.nvim
|
||||
url = https://github.com/folke/trouble.nvim
|
||||
|
||||
# auto close brackets and quotes
|
||||
# coding.vim
|
||||
[submodule "src/.local/share/nvim/site/pack/3pp/start/auto-pairs"]
|
||||
@ -51,13 +54,10 @@
|
||||
url = https://github.com/puremourning/vimspector.git
|
||||
|
||||
# language smarts
|
||||
# coding.vim
|
||||
# coding.lua
|
||||
[submodule "src/.local/share/nvim/site/pack/3pp/start/nvim-lspconfig"]
|
||||
path = src/.local/share/nvim/site/pack/3pp/start/nvim-lspconfig
|
||||
url = https://github.com/neovim/nvim-lspconfig.git
|
||||
[submodule "src/.local/share/nvim/site/pack/3pp/start/lsp-status.nvim"]
|
||||
path = src/.local/share/nvim/site/pack/3pp/start/lsp-status.nvim
|
||||
url = https://github.com/nvim-lua/lsp-status.nvim.git
|
||||
[submodule "src/.local/share/nvim/site/pack/3pp/start/nvim-cmp"]
|
||||
path = src/.local/share/nvim/site/pack/3pp/start/nvim-cmp
|
||||
url = https://github.com/hrsh7th/nvim-cmp.git
|
||||
@ -68,8 +68,14 @@
|
||||
path = src/.local/share/nvim/site/pack/3pp/start/nvim-treesitter
|
||||
url = https://github.com/nvim-treesitter/nvim-treesitter.git
|
||||
|
||||
# error/warning/info box
|
||||
# coding.lua
|
||||
[submodule "src/.local/share/nvim/site/pack/3pp/start/trouble.nvim"]
|
||||
path = src/.local/share/nvim/site/pack/3pp/start/trouble.nvim
|
||||
url = https://github.com/folke/trouble.nvim
|
||||
|
||||
# aesthetic changes
|
||||
# coding.vim
|
||||
# init.lua
|
||||
[submodule "src/.local/share/nvim/site/pack/3pp/start/dressing.nvim"]
|
||||
path = src/.local/share/nvim/site/pack/3pp/start/dressing.nvim
|
||||
url = https://github.com/stevearc/dressing.nvim.git
|
||||
|
17
README.md
17
README.md
@ -4,6 +4,15 @@ My dotfiles.
|
||||
|
||||
## Installation
|
||||
|
||||
Clone with submodules (this is necessary for Neovim plugins):
|
||||
|
||||
```bash
|
||||
git clone --recurse-submodules https://github.com/dogeystamp/dots.git
|
||||
# alternatively, after cloning:
|
||||
git submodule init
|
||||
git submodule update
|
||||
```
|
||||
|
||||
Symlink all the files in src/ to your home directory using the provided dotinstall.sh script, or manually.
|
||||
Otherwise, copy them manually to your home directory.
|
||||
|
||||
@ -22,9 +31,13 @@ once the dotfiles are installed, see `~/.config/dot_profile.example` for more in
|
||||
|
||||
### Notes
|
||||
|
||||
`.local/bin/keyboard.sh` provides changes I like, such as swapping escape and caps lock, which you should remove if you don't need.
|
||||
- `.local/bin/keyboard.sh` provides changes I like, such as swapping escape and caps lock, which you should remove if you don't need.
|
||||
|
||||
My qutebrowser configuration emphasizes privacy over usability, and you might need to edit it to suit your needs if you want to use it.
|
||||
- My qutebrowser configuration emphasizes privacy over usability, and you might need to edit it to suit your needs if you want to use it.
|
||||
|
||||
- Neovim plugins are installed [via git submodule](https://hiphish.github.io/blog/2021/12/05/managing-vim-plugins-without-plugin-manager/)
|
||||
rather than through conventional means. This has less complexity than a plugin manager since I already manage all my dotfiles under Git.
|
||||
Plugins are declared in `.gitmodules`.
|
||||
|
||||
**Desktop Preview**
|
||||
|
||||
|
140
src/.config/nvim/lua/coding.lua
Normal file
140
src/.config/nvim/lua/coding.lua
Normal file
@ -0,0 +1,140 @@
|
||||
-- stuff for coding
|
||||
|
||||
|
||||
|
||||
------
|
||||
-- syntax highlighting
|
||||
-- plug: nvim-treesitter
|
||||
------
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
ensure_installed = { "c", "cpp", "javascript", "typescript", "python", "vim", "fish", "bash" },
|
||||
sync_install = false,
|
||||
auto_install = false,
|
||||
highlight = {
|
||||
enable = true,
|
||||
|
||||
disable = function(lang, buf)
|
||||
local max_filesize = 100 * 1024 -- 100 KB
|
||||
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||
if ok and stats and stats.size > max_filesize then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
------
|
||||
-- diagnostics box
|
||||
-- plug: trouble.nvim
|
||||
------
|
||||
require('trouble').setup({
|
||||
icons = false,
|
||||
fold_open = "v", -- icon used for open folds
|
||||
fold_closed = ">", -- icon used for closed folds
|
||||
indent_lines = false, -- add an indent guide below the fold icons
|
||||
signs = {
|
||||
-- icons / text used for a diagnostic
|
||||
error = "error",
|
||||
warning = "warn",
|
||||
hint = "hint",
|
||||
information = "info"
|
||||
},
|
||||
use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client
|
||||
})
|
||||
|
||||
|
||||
|
||||
--------------------------------
|
||||
--------------------------------
|
||||
-- language smarts (LSP and completion)
|
||||
--------------------------------
|
||||
--------------------------------
|
||||
|
||||
------
|
||||
-- language server (LSP)
|
||||
-- plug: nvim-lspconfig
|
||||
------
|
||||
local on_attach = function(client, bufnr)
|
||||
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
||||
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
local opts = { noremap=true, silent=true }
|
||||
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
buf_set_keymap('n', 'gK', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
buf_set_keymap('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
buf_set_keymap('n', 'gt', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>ss', '<cmd>lua vim.lsp.buf.workspace_symbol()<CR>', opts)
|
||||
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
||||
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.format()<CR>', opts)
|
||||
end
|
||||
|
||||
-- table declares LSPs to be set up
|
||||
-- as well as settings per server (overrides defaults)
|
||||
local servers = {
|
||||
--pyright = {},
|
||||
pylsp = {
|
||||
settings = {
|
||||
plugins = {
|
||||
['python-lsp-black'] = {},
|
||||
['python-pyflakes'] = {},
|
||||
['pylsp-mypy'] = {},
|
||||
},
|
||||
},
|
||||
},
|
||||
clangd = {},
|
||||
tsserver = {},
|
||||
bashls = {},
|
||||
cssls = {},
|
||||
rust_analyzer = {
|
||||
settings = {
|
||||
['rust-analyzer'] = {
|
||||
check = {
|
||||
allTargets = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
local nvim_lsp = require('lspconfig')
|
||||
for lsp, sv_settings in pairs(servers) do
|
||||
-- defaults
|
||||
settings = {
|
||||
on_attach = on_attach,
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
}
|
||||
}
|
||||
for k, v in pairs(servers[lsp]) do settings[k] = v end
|
||||
nvim_lsp[lsp].setup(settings)
|
||||
end
|
||||
|
||||
|
||||
------
|
||||
-- completions
|
||||
-- plug: nvim-cmp, cmp-nvim-lsp
|
||||
------
|
||||
local cmp = require('cmp')
|
||||
cmp.setup({
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<C-f>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
@ -1,22 +1,13 @@
|
||||
-- Syntax highlighting
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
ensure_installed = { "c", "cpp", "javascript", "typescript", "python", "vim", "fish", "bash" },
|
||||
sync_install = false,
|
||||
auto_install = false,
|
||||
highlight = {
|
||||
enable = true,
|
||||
--------------------------------
|
||||
--------------------------------
|
||||
-- miscellaneous plugins
|
||||
--------------------------------
|
||||
--------------------------------
|
||||
|
||||
disable = function(lang, buf)
|
||||
local max_filesize = 100 * 1024 -- 100 KB
|
||||
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||
if ok and stats and stats.size > max_filesize then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
-- motions to hop between URLs fast
|
||||
------
|
||||
-- url motions
|
||||
-- plug: urlview.nvim
|
||||
------
|
||||
require("urlview").setup({
|
||||
jump = {
|
||||
prev = "<leader>uj",
|
||||
@ -24,104 +15,23 @@ require("urlview").setup({
|
||||
},
|
||||
})
|
||||
|
||||
local on_attach = function(client, bufnr)
|
||||
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
||||
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
local opts = { noremap=true, silent=true }
|
||||
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
buf_set_keymap('n', 'gK', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
buf_set_keymap('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
buf_set_keymap('n', 'gt', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>ss', '<cmd>lua vim.lsp.buf.workspace_symbol()<CR>', opts)
|
||||
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
||||
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.format()<CR>', opts)
|
||||
end
|
||||
|
||||
-- settings per server (overrides defaults)
|
||||
local servers = {
|
||||
--pyright = {},
|
||||
pylsp = {
|
||||
settings = {
|
||||
plugins = {
|
||||
['python-lsp-black'] = {},
|
||||
['python-pyflakes'] = {},
|
||||
['pylsp-mypy'] = {},
|
||||
},
|
||||
},
|
||||
},
|
||||
clangd = {},
|
||||
tsserver = {},
|
||||
bashls = {},
|
||||
cssls = {},
|
||||
rust_analyzer = {
|
||||
settings = {
|
||||
['rust-analyzer'] = {
|
||||
check = {
|
||||
allTargets = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local nvim_lsp = require('lspconfig')
|
||||
for lsp, sv_settings in pairs(servers) do
|
||||
-- defaults
|
||||
settings = {
|
||||
on_attach = on_attach,
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
}
|
||||
}
|
||||
for k, v in pairs(servers[lsp]) do settings[k] = v end
|
||||
nvim_lsp[lsp].setup(settings)
|
||||
end
|
||||
|
||||
------
|
||||
-- fancy prompts
|
||||
-- plug: dressing.nvim
|
||||
------
|
||||
require('dressing').setup({
|
||||
input = {
|
||||
insert_only = false,
|
||||
}
|
||||
})
|
||||
|
||||
local cmp = require'cmp'
|
||||
cmp.setup({
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<C-f>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- improved error list
|
||||
require('trouble').setup({
|
||||
icons = false,
|
||||
fold_open = "v", -- icon used for open folds
|
||||
fold_closed = ">", -- icon used for closed folds
|
||||
indent_lines = false, -- add an indent guide below the fold icons
|
||||
signs = {
|
||||
-- icons / text used for a diagnostic
|
||||
error = "error",
|
||||
warning = "warn",
|
||||
hint = "hint",
|
||||
information = "info"
|
||||
},
|
||||
use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client
|
||||
})
|
||||
|
||||
--------------------------------
|
||||
--------------------------------
|
||||
-- imports (see .config/nvim/lua/)
|
||||
--------------------------------
|
||||
--------------------------------
|
||||
|
||||
require("coding")
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit 54f48eb5017632d81d0fd40112065f1d062d0629
|
Loading…
Reference in New Issue
Block a user