|
83 | 83 | ---@param buf integer |
84 | 84 | ---@return boolean |
85 | 85 | function M.should_attach(buf) |
86 | | - local file = vim.api.nvim_buf_get_name(buf) |
87 | | - local log_name = string.format('attach %s', vim.fn.fnamemodify(file, ':t')) |
88 | | - log.buf('info', log_name, buf, 'start') |
| 86 | + log.buf('info', 'attach', buf, 'start') |
89 | 87 |
|
90 | 88 | if vim.tbl_contains(buffers, buf) then |
91 | | - log.buf('info', log_name, buf, 'skip', 'already attached') |
| 89 | + log.buf('info', 'attach', buf, 'skip', 'already attached') |
92 | 90 | return false |
93 | 91 | end |
94 | 92 |
|
95 | 93 | local file_type, file_types = util.get('buf', buf, 'filetype'), state.file_types |
96 | 94 | if not vim.tbl_contains(file_types, file_type) then |
97 | 95 | local reason = string.format('%s /∈ %s', file_type, vim.inspect(file_types)) |
98 | | - log.buf('info', log_name, buf, 'skip', 'file type', reason) |
| 96 | + log.buf('info', 'attach', buf, 'skip', 'file type', reason) |
99 | 97 | return false |
100 | 98 | end |
101 | 99 |
|
102 | 100 | local config = state.get(buf) |
103 | 101 | if not config.enabled then |
104 | | - log.buf('info', log_name, buf, 'skip', 'state disabled') |
| 102 | + log.buf('info', 'attach', buf, 'skip', 'state disabled') |
105 | 103 | return false |
106 | 104 | end |
107 | 105 |
|
108 | | - local file_size, max_file_size = util.file_size_mb(file), config.max_file_size |
| 106 | + local file_size, max_file_size = util.file_size_mb(buf), config.max_file_size |
109 | 107 | if file_size > max_file_size then |
110 | 108 | local reason = string.format('%f > %f', file_size, max_file_size) |
111 | | - log.buf('info', log_name, buf, 'skip', 'file size', reason) |
| 109 | + log.buf('info', 'attach', buf, 'skip', 'file size', reason) |
112 | 110 | return false |
113 | 111 | end |
114 | 112 |
|
115 | | - log.buf('info', log_name, buf, 'success') |
| 113 | + log.buf('info', 'attach', buf, 'success') |
116 | 114 | table.insert(buffers, buf) |
117 | 115 | return true |
118 | 116 | end |
|
0 commit comments