-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
274 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Welcome to my dotfiles | ||
|
||
If you are new to Lua, I highly recommend checking out [Nanotee's Lua Guide](https://github.com/nanotee/nvim-lua-guide). | ||
|
||
- you can find my plugins in ~/.config/nvim/after/plugins | ||
- you can find my customizations in ~/.config/nvim/lua/me |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
local globals = { | ||
mapleader = " ", | ||
glow_binary_path = vim.env.HOME .. "/bin", | ||
glow_use_pager = true, | ||
glow_border = "shadow", | ||
} | ||
|
||
for k, v in pairs(globals) do | ||
vim.g[k] = v | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
local keymap = function(tbl) | ||
local opts = { noremap = true, silent = true } | ||
local mode = tbl['mode'] | ||
tbl['mode'] = nil | ||
local bufnr = tbl['bufnr'] | ||
tbl['bufnr'] = nil | ||
|
||
for k, v in pairs(tbl) do | ||
if tonumber(k) == nil then | ||
opts[k] = v | ||
end | ||
end | ||
|
||
if bufnr ~= nil then | ||
vim.api.nvim_buf_set_keymap(bufnr, mode, tbl[1], tbl[2], opts) | ||
else | ||
vim.api.nvim_set_keymap(mode, tbl[1], tbl[2], opts) | ||
end | ||
end | ||
|
||
nmap = function(tbl) | ||
tbl['mode'] = 'n' | ||
keymap(tbl) | ||
end | ||
|
||
imap = function(tbl) | ||
tbl['mode'] = 'i' | ||
keymap(tbl) | ||
end | ||
|
||
|
||
local ok, treesitter = pcall(require, "nvim-treesitter.configs") | ||
if not ok then return end | ||
treesitter.setup { ensure_installed = "all", highlight = { enable = true } } | ||
|
||
-- keymaps | ||
vim.keymap.set("n", "<leader>p", "<cmd>Glow<cr>") | ||
nmap{"<C-f>", "<cmd>Telescope current_buffer_fuzzy_find sorting_strategy=ascending prompt_position=top<CR>"} | ||
nmap{"<leader>lg", "<cmd>Telescope live_grep<CR>"} | ||
nmap{"<leader>dl", "<cmd>Telescope diagnostics<cr>"} | ||
|
||
-- navigation | ||
nmap{"L", "<cmd>bnext<cr>"} | ||
nmap{"H", "<cmd>bprevious<cr>"} | ||
nmap{"F", "<cmd>HopPattern<cr>"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
-- Native LSP Setup | ||
require("me.keymap") | ||
-- Global setup. | ||
local cmp = require'cmp' | ||
cmp.setup({ | ||
snippet = { | ||
expand = function(args) | ||
require('luasnip').lsp_expand(args.body) -- For `luasnip` users. | ||
end, | ||
}, | ||
mapping = { | ||
['<Tab>'] = function(fallback) | ||
if cmp.visible() then | ||
cmp.select_next_item() | ||
else | ||
fallback() | ||
end | ||
end | ||
}, | ||
|
||
sources = cmp.config.sources({ | ||
{ name = 'nvim_lsp' }, | ||
{ name = 'luasnip' }, -- For luasnip users. | ||
}, { | ||
{ name = 'buffer' }, | ||
}) | ||
}) | ||
|
||
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) | ||
|
||
-- Use an on_attach function to only map the following keys | ||
-- after the language server attaches to the current buffer | ||
local lsp_installer = require("nvim-lsp-installer") | ||
lsp_installer.settings({ | ||
ui = { | ||
icons = { | ||
server_installed = "✓", | ||
server_pending = "➜", | ||
server_uninstalled = "✗" | ||
} | ||
} | ||
}) | ||
|
||
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) | ||
local on_attach = function(client, bufnr) | ||
|
||
local function buf_set_keymap(...) | ||
vim.api.nvim_buf_set_keymap(bufnr, ...) | ||
end | ||
|
||
-- Mappings. | ||
local opts = { noremap = true, silent = true } | ||
|
||
-- See `:help vim.lsp.*` for documentation on any of the below functions | ||
-- leaving only what I actually use... | ||
nmap{"K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts} | ||
-- buf_set_keymap("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts) | ||
nmap{"gd", "<cmd>Telescope lsp_definitions<CR>", opts} | ||
nmap{"gr", "<cmd>Telescope lsp_references<CR>", opts} | ||
nmap{"<C-j>", "<cmd>Telescope lsp_document_symbols<CR>", opts} | ||
nmap{"<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts} | ||
|
||
nmap{"gi", "<cmd>Telescope lsp_implementations<CR>", opts} | ||
nmap{"<leader>D", "<cmd>Telescope lsp_type_definitions<CR>", opts} | ||
nmap{"<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts} | ||
nmap{'<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts} | ||
nmap{"gt", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts} | ||
nmap{"gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts} | ||
nmap{"<leader>dj", "<cmd>lua vim.diagnostic.goto_next()<CR>", opts} | ||
nmap{"<leader>dk", "<cmd>lua vim.diagnostic.goto_prev()<CR>", opts} | ||
nmap{"<leader>r", "<cmd>lua vim.lsp.buf.rename()<CR>", opts} | ||
|
||
vim.cmd([[ | ||
augroup formatting | ||
autocmd! * <buffer> | ||
autocmd BufWritePre <buffer> lua vim.lsp.buf.format() | ||
autocmd BufWritePre <buffer> lua OrganizeImports(1000) | ||
augroup END | ||
]]) | ||
|
||
-- Set autocommands conditional on server_capabilities | ||
vim.cmd([[ | ||
augroup lsp_document_highlight | ||
autocmd! * <buffer> | ||
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight() | ||
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references() | ||
augroup END | ||
]]) | ||
end | ||
|
||
-- organize imports | ||
-- https://github.com/neovim/nvim-lspconfig/issues/115#issuecomment-902680058 | ||
function OrganizeImports(timeoutms) | ||
local params = vim.lsp.util.make_range_params() | ||
params.context = { only = { "source.organizeImports" } } | ||
local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, timeoutms) | ||
for _, res in pairs(result or {}) do | ||
for _, r in pairs(res.result or {}) do | ||
if r.edit then | ||
vim.lsp.util.apply_workspace_edit(r.edit, "UTF-8") | ||
else | ||
vim.lsp.buf.execute_command(r.command) | ||
end | ||
end | ||
end | ||
end | ||
|
||
lsp_installer.setup{} | ||
local lspconfig = require('lspconfig') | ||
lspconfig.gopls.setup { | ||
capabilities = capabilities, | ||
on_attach = on_attach, | ||
settings = { | ||
gopls = { | ||
gofumpt = true, | ||
}, | ||
}, | ||
flags = { | ||
debounce_text_changes = 150, | ||
}, | ||
} | ||
|
||
lspconfig.golangci_lint_ls.setup { | ||
capabilities = capabilities, | ||
on_attach = on_attach, | ||
settings = { | ||
gopls = { | ||
gofumpt = true, | ||
}, | ||
}, | ||
flags = { | ||
debounce_text_changes = 150, | ||
}, | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require('lualine').setup{ | ||
options = { | ||
theme = 'auto', | ||
}, | ||
sections = { | ||
lualine_a = {'mode'}, | ||
lualine_b = {'branch', 'diff'}, | ||
lualine_c = {'buffers'}, | ||
lualine_x = {'tabs'}, | ||
lualine_y = {'progress'}, | ||
lualine_z = { | ||
{ 'diagnostics', | ||
sources = {'nvim_diagnostic', 'nvim_lsp'}, | ||
sections = {'error', 'warn', 'info', 'hint'}, | ||
diagnostics_color = { | ||
-- Same values as the general color option can be used here. | ||
error = 'DiagnosticError', -- Changes diagnostics' error color. | ||
warn = 'DiagnosticWarn', -- Changes diagnostics' warn color. | ||
info = 'DiagnosticInfo', -- Changes diagnostics' info color. | ||
hint = 'DiagnosticHint', -- Changes diagnostics' hint color. | ||
}, | ||
symbols = {error = 'E', warn = 'W', info = 'I', hint = 'H'}, | ||
colored = true, -- Displays diagnostics status in color if set to true. | ||
update_in_insert = false, -- Update diagnostics in insert mode. | ||
always_visible = false, -- Show diagnostics even if there are none. | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
local options = { | ||
ma = true, | ||
mouse = "a", | ||
cursorline = true, | ||
tabstop = 4, | ||
shiftwidth = 4, | ||
softtabstop = 4, | ||
expandtab = true, | ||
autoread = true, | ||
nu = true, | ||
foldlevelstart = 99, | ||
scrolloff = 7, | ||
backup = false, | ||
writebackup = false, | ||
swapfile = false, | ||
clipboard = "unnamedplus", | ||
} | ||
|
||
for k, v in pairs(options) do | ||
vim.opt[k] = v | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- Telescope Setup | ||
local action_state = require('telescope.actions.state') -- runtime (Plugin) exists somewhere as lua/telescope/actions/state.lua | ||
require('telescope').setup{ | ||
defaults = { | ||
prompt_prefix = "$ ", | ||
mappings = { | ||
i = { | ||
["<c-a>"] = function() print(vim.inspect(action_state.get_selected_entry())) end | ||
} | ||
} | ||
} | ||
} | ||
require('telescope').load_extension('fzf') | ||
require('telescope').load_extension('file_browser') | ||
|
||
|
||
local mappings = {} | ||
mappings.curr_buf = function() | ||
local opt = require('telescope.themes').get_dropdown({height=10, previewer=false}) | ||
require('telescope.builtin').current_buffer_fuzzy_find(opt) | ||
end | ||
return mappings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters